From e1b354e67b0efc59cb65e57eb5b86f7f1919bb69 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sun, 26 Jan 2025 17:55:34 +0000 Subject: [PATCH] Implemented `GetFleaPriceForOfferItems` --- Libraries/Core/Models/Spt/Config/ItemConfig.cs | 12 ++++++------ Libraries/Core/Services/RagfairPriceService.cs | 15 +++++++++++---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Libraries/Core/Models/Spt/Config/ItemConfig.cs b/Libraries/Core/Models/Spt/Config/ItemConfig.cs index 2c962201..e57d2418 100644 --- a/Libraries/Core/Models/Spt/Config/ItemConfig.cs +++ b/Libraries/Core/Models/Spt/Config/ItemConfig.cs @@ -1,4 +1,4 @@ -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; using Core.Models.Eft.Common; namespace Core.Models.Spt.Config; @@ -10,23 +10,23 @@ public record ItemConfig : BaseConfig /** Items that should be globally blacklisted */ [JsonPropertyName("blacklist")] - public List Blacklist { get; set; } + public HashSet Blacklist { get; set; } /** Items that should not be lootable from any location */ [JsonPropertyName("lootableItemBlacklist")] - public List LootableItemBlacklist { get; set; } + public HashSet LootableItemBlacklist { get; set; } /** items that should not be given as rewards */ [JsonPropertyName("rewardItemBlacklist")] - public List RewardItemBlacklist { get; set; } + public HashSet RewardItemBlacklist { get; set; } /** Item base types that should not be given as rewards */ [JsonPropertyName("rewardItemTypeBlacklist")] - public List RewardItemTypeBlacklist { get; set; } + public HashSet RewardItemTypeBlacklist { get; set; } /** Items that can only be found on bosses */ [JsonPropertyName("bossItems")] - public List BossItems { get; set; } + public HashSet BossItems { get; set; } [JsonPropertyName("handbookPriceOverride")] public Dictionary HandbookPriceOverride { get; set; } diff --git a/Libraries/Core/Services/RagfairPriceService.cs b/Libraries/Core/Services/RagfairPriceService.cs index 7b35d94d..266c6e7e 100644 --- a/Libraries/Core/Services/RagfairPriceService.cs +++ b/Libraries/Core/Services/RagfairPriceService.cs @@ -34,12 +34,13 @@ public class RagfairPriceService( /// public async Task OnLoadAsync() { - throw new NotImplementedException(); + RefreshStaticPrices(); + RefreshDynamicPrices(); } public string GetRoute() { - throw new NotImplementedException(); + return "RagfairPriceService"; } /// @@ -58,7 +59,7 @@ public class RagfairPriceService( /// public void RefreshDynamicPrices() { - throw new NotImplementedException(); + // TODO: remove as redundant? } /// @@ -95,7 +96,13 @@ public class RagfairPriceService( /// Rouble price public double GetFleaPriceForOfferItems(List offerItems) { - throw new NotImplementedException(); + // Preset weapons take the direct prices.json value, otherwise they're massivly inflated + if (_itemHelper.IsOfBaseclass(offerItems[0].Template, BaseClasses.WEAPON)) + { + return GetFleaPriceForItem(offerItems[0].Template); + } + + return offerItems.Sum(item => GetFleaPriceForItem(item.Template)); } ///