diff --git a/Libraries/SPTarkov.Server.Core/Controllers/InsuranceController.cs b/Libraries/SPTarkov.Server.Core/Controllers/InsuranceController.cs index ebb246f7..b653942b 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/InsuranceController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/InsuranceController.cs @@ -492,11 +492,11 @@ public class InsuranceController( ); // Create prob array and add all attachments with rouble price as the weight - var attachmentsProbabilityArray = new ProbabilityObjectArray(_cloner); + var attachmentsProbabilityArray = new ProbabilityObjectArray(_cloner); foreach (var (itemTpl, price) in weightedAttachmentByPrice) { attachmentsProbabilityArray.Add( - new ProbabilityObject(itemTpl, price, null) + new ProbabilityObject(itemTpl, price, null) ); } @@ -525,9 +525,9 @@ public class InsuranceController( /// /// protected void LogAttachmentsBeingRemoved( - List attachmentIdsToRemove, + List attachmentIdsToRemove, List attachments, - Dictionary attachmentPrices + Dictionary attachmentPrices ) { var index = 1; @@ -550,9 +550,9 @@ public class InsuranceController( /// /// Item attachments /// - protected Dictionary WeightAttachmentsByPrice(List attachments) + protected Dictionary WeightAttachmentsByPrice(List attachments) { - var result = new Dictionary(); + var result = new Dictionary(); // Get a dictionary of item tpls + their rouble price foreach (var attachment in attachments) @@ -579,7 +579,7 @@ public class InsuranceController( /// Trader the attachment is insured against /// Attachment count to remove protected double GetAttachmentCountToRemove( - Dictionary weightedAttachmentByPrice, + Dictionary weightedAttachmentByPrice, string? traderId ) { diff --git a/Libraries/SPTarkov.Server.Core/Controllers/InventoryController.cs b/Libraries/SPTarkov.Server.Core/Controllers/InventoryController.cs index 6f19dfaf..2bec0c98 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/InventoryController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/InventoryController.cs @@ -599,7 +599,7 @@ public class InventoryController( /// /// Session/Player id /// Item tpl - protected string? GetExaminedItemTpl(InventoryExamineRequestData request, string? sessionId) + protected MongoId? GetExaminedItemTpl(InventoryExamineRequestData request, string? sessionId) { if (_presetHelper.IsPreset(request.Item)) { diff --git a/Libraries/SPTarkov.Server.Core/Controllers/PresetController.cs b/Libraries/SPTarkov.Server.Core/Controllers/PresetController.cs index eea39734..349f6f09 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/PresetController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/PresetController.cs @@ -1,5 +1,6 @@ using SPTarkov.DI.Annotations; using SPTarkov.Server.Core.Helpers; +using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Models.Spt.Presets; using SPTarkov.Server.Core.Models.Utils; using SPTarkov.Server.Core.Services; @@ -19,7 +20,7 @@ public class PresetController( public void Initialize() { var presets = _databaseService.GetGlobals().ItemPresets; - var result = new Dictionary(); + var result = new Dictionary(); foreach (var (presetId, preset) in presets) { if (presetId != preset.Id) @@ -33,9 +34,9 @@ public class PresetController( // Get root items tpl var tpl = preset.Items.FirstOrDefault()?.Template; - result.TryAdd(tpl, new PresetCacheDetails { PresetIds = [] }); + result.TryAdd(tpl.Value, new PresetCacheDetails { PresetIds = [] }); - result.TryGetValue(tpl, out var details); + result.TryGetValue(tpl.Value, out var details); details.PresetIds.Add(presetId); if (preset.Encyclopedia is not null) { diff --git a/Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs b/Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs index 01132526..ecba236a 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs @@ -1326,12 +1326,12 @@ public class RagfairController /// Get prices for all items on flea /// /// Dictionary of tpl and item price - public Dictionary GetAllFleaPrices() + public Dictionary GetAllFleaPrices() { return _ragfairPriceService.GetAllFleaPrices(); } - public Dictionary GetStaticPrices() + public Dictionary GetStaticPrices() { return _ragfairPriceService.GetAllStaticPrices(); } diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotEquipmentModGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotEquipmentModGenerator.cs index 888e3c47..801cde23 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotEquipmentModGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotEquipmentModGenerator.cs @@ -186,7 +186,8 @@ public class BotEquipmentModGenerator( ); switch (plateSlotFilteringOutcome.Result) { - case Result.UNKNOWN_FAILURE or Result.NO_DEFAULT_FILTER: + case Result.UNKNOWN_FAILURE + or Result.NO_DEFAULT_FILTER: if (_logger.IsLogEnabled(LogLevel.Debug)) { _logger.Debug( @@ -207,7 +208,7 @@ public class BotEquipmentModGenerator( } // Choose random mod from pool and check its compatibility - string? modTpl = null; + MongoId? modTpl = null; var found = false; var exhaustableModPool = CreateExhaustableArray(modPoolToChooseFrom); while (exhaustableModPool.HasValues()) @@ -216,7 +217,7 @@ public class BotEquipmentModGenerator( if ( modTpl is not null && !_botGeneratorHelper - .IsItemIncompatibleWithCurrentItems(equipment, modTpl, modSlotName) + .IsItemIncompatibleWithCurrentItems(equipment, modTpl.Value, modSlotName) .Incompatible.GetValueOrDefault(false) ) { @@ -244,7 +245,7 @@ public class BotEquipmentModGenerator( } // Get chosen mods db template and check it fits into slot - var modTemplate = _itemHelper.GetItem(modTpl); + var modTemplate = _itemHelper.GetItem(modTpl.Value); if ( !IsModValidForSlot( modTemplate, @@ -855,7 +856,7 @@ public class BotEquipmentModGenerator( /// Slot to check /// /// true if it's a front/rear sight - public bool ModIsFrontOrRearSight(string modSlot, string tpl) + public bool ModIsFrontOrRearSight(string modSlot, MongoId tpl) { // Gas block /w front sight is special case, deem it a 'front sight' too if (modSlot == "mod_gas_block" && tpl == "5ae30e795acfc408fb139a0b") @@ -1705,7 +1706,7 @@ public class BotEquipmentModGenerator( /// Slot to get mod to fill /// Items to ensure picked mod is compatible with /// Item tpl - public string? GetRandomModTplFromItemDb( + public MongoId? GetRandomModTplFromItemDb( string fallbackModTpl, Slot parentSlot, string modSlot, diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs index 5843306c..b426e755 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs @@ -474,7 +474,7 @@ public class BotGenerator( /// Bot to filter public void RemoveBlacklistedLootFromBotTemplate(BotTypeInventory botInventory) { - var containersToProcess = new List> + var containersToProcess = new List> { botInventory.Items.Backpack, botInventory.Items.Pockets, diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotLootGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotLootGenerator.cs index 82388f70..e406841f 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotLootGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotLootGenerator.cs @@ -458,7 +458,7 @@ public class BotLootGenerator( { // surv12 AddLootFromPool( - new Dictionary { { "5d02797c86f774203f38e30a", 1 } }, + new Dictionary { { "5d02797c86f774203f38e30a", 1 } }, [EquipmentSlots.SecuredContainer], 1, botInventory, @@ -470,7 +470,7 @@ public class BotLootGenerator( // AFAK AddLootFromPool( - new Dictionary { { "60098ad7c2240c0fe85c570a", 1 } }, + new Dictionary { { "60098ad7c2240c0fe85c570a", 1 } }, [EquipmentSlots.SecuredContainer], 10, botInventory, @@ -494,7 +494,7 @@ public class BotLootGenerator( /// Total value of loot allowed in roubles /// Is bot being generated for a pmc protected void AddLootFromPool( - Dictionary pool, + Dictionary pool, HashSet equipmentSlots, double totalItemCount, BotBaseInventory inventoryToAddItemsTo, diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs index 13926038..73deb67d 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs @@ -545,7 +545,7 @@ public class BotWeaponGenerator( GenerationData ubglMinMax = new() { Weights = new Dictionary { { 1, 1 }, { 2, 1 } }, - Whitelist = new Dictionary(), + Whitelist = new Dictionary(), }; // get ammo template from db diff --git a/Libraries/SPTarkov.Server.Core/Generators/LocationLootGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/LocationLootGenerator.cs index b1c226a6..06d00e1f 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/LocationLootGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/LocationLootGenerator.cs @@ -696,7 +696,7 @@ public class LocationLootGenerator( /// Container to get possible loot for /// staticLoot.json /// ProbabilityObjectArray of item tpls + probability - protected ProbabilityObjectArray GetPossibleLootItemsForContainer( + protected ProbabilityObjectArray GetPossibleLootItemsForContainer( string containerTypeId, Dictionary staticLootDist ) @@ -704,7 +704,7 @@ public class LocationLootGenerator( var seasonalEventActive = _seasonalEventService.SeasonalEventEnabled(); var seasonalItemTplBlacklist = _seasonalEventService.GetInactiveSeasonalEventItems(); - var itemDistribution = new ProbabilityObjectArray(_cloner); + var itemDistribution = new ProbabilityObjectArray(_cloner); var itemContainerDistribution = staticLootDist[containerTypeId]?.ItemDistribution; if (itemContainerDistribution is null) @@ -734,7 +734,7 @@ public class LocationLootGenerator( } itemDistribution.Add( - new ProbabilityObject(icd.Tpl, icd.RelativeProbability.Value, null) + new ProbabilityObject(icd.Tpl, icd.RelativeProbability.Value, null) ); } diff --git a/Libraries/SPTarkov.Server.Core/Generators/PMCLootGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/PMCLootGenerator.cs index b26449db..807e500b 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/PMCLootGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/PMCLootGenerator.cs @@ -25,9 +25,9 @@ public class PMCLootGenerator( private readonly PmcConfig _pmcConfig = configServer.GetConfig(); // Store loot against its type, usec/bear - private readonly Dictionary>? _backpackLootPool = []; - private readonly Dictionary>? _pocketLootPool = []; - private readonly Dictionary>? _vestLootPool = []; + private readonly Dictionary>? _backpackLootPool = []; + private readonly Dictionary>? _pocketLootPool = []; + private readonly Dictionary>? _vestLootPool = []; protected readonly Lock BackpackLock = new(); protected readonly Lock PocketLock = new(); @@ -38,7 +38,7 @@ public class PMCLootGenerator( /// /// Role of PMC having loot generated (bear or usec) /// Dictionary of string and number - public Dictionary GeneratePMCPocketLootPool(string pmcRole) + public Dictionary GeneratePMCPocketLootPool(string pmcRole) { lock (PocketLock) { @@ -72,7 +72,7 @@ public class PMCLootGenerator( /// /// Role of PMC having loot generated (bear or usec) /// Dictionary item template ids and a weighted chance of being picked - public Dictionary GeneratePMCVestLootPool(string pmcRole) + public Dictionary GeneratePMCVestLootPool(string pmcRole) { lock (VestLock) { @@ -107,7 +107,7 @@ public class PMCLootGenerator( /// /// Role of PMC having loot generated (bear or usec) /// Dictionary of string and number - public Dictionary GeneratePMCBackpackLootPool(string pmcRole) + public Dictionary GeneratePMCBackpackLootPool(string pmcRole) { lock (BackpackLock) { @@ -137,14 +137,14 @@ public class PMCLootGenerator( /// Item and parent blacklist /// An optional delegate to validate the TemplateItem object being processed /// Dictionary of items and weights inversely tied to the items price - protected Dictionary GenerateLootPool( + protected Dictionary GenerateLootPool( string pmcRole, HashSet allowedItemTypeWhitelist, HashSet itemTplAndParentBlacklist, Func? genericItemCheck ) { - var lootPool = new Dictionary(); + var lootPool = new Dictionary(); var items = databaseService.GetItems(); // Grab price overrides if they exist for the pmcRole passed in @@ -207,7 +207,7 @@ public class PMCLootGenerator( /// /// role of PMC to look up /// Dictionary of overrides - protected Dictionary? GetPMCPriceOverrides(string pmcRole) + protected Dictionary? GetPMCPriceOverrides(string pmcRole) { var pmcType = string.Equals(pmcRole, "pmcbear", StringComparison.OrdinalIgnoreCase) ? "bear" @@ -229,7 +229,10 @@ public class PMCLootGenerator( /// Item tpl to get price of /// /// Rouble price - protected double GetItemPrice(string tpl, Dictionary? pmcPriceOverrides = null) + protected double GetItemPrice( + MongoId tpl, + Dictionary? pmcPriceOverrides = null + ) { if ( pmcPriceOverrides is not null diff --git a/Libraries/SPTarkov.Server.Core/Generators/RagfairAssortGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/RagfairAssortGenerator.cs index 36b784bb..9ecfef97 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/RagfairAssortGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/RagfairAssortGenerator.cs @@ -132,7 +132,7 @@ public class RagfairAssortGenerator( /// tplid to add to item /// id to add to item /// Hydrated Item object - protected Item CreateRagfairAssortRootItem(string tplId, MongoId? id = null) + protected Item CreateRagfairAssortRootItem(MongoId tplId, MongoId? id = null) { if (string.IsNullOrEmpty(id)) { diff --git a/Libraries/SPTarkov.Server.Core/Generators/RagfairOfferGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/RagfairOfferGenerator.cs index 9f2a7708..39391472 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/RagfairOfferGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/RagfairOfferGenerator.cs @@ -786,7 +786,7 @@ public class RagfairOfferGenerator( /// /// Item to look for matching condition object /// Condition ID - protected string? GetDynamicConditionIdForTpl(string tpl) + protected string? GetDynamicConditionIdForTpl(MongoId tpl) { // Get keys from condition config dictionary var configConditions = ragfairConfig.Dynamic.Condition.Keys; diff --git a/Libraries/SPTarkov.Server.Core/Generators/RepeatableQuestGeneration/RepeatableQuestRewardGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/RepeatableQuestGeneration/RepeatableQuestRewardGenerator.cs index 4cf4765b..f82a0cad 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/RepeatableQuestGeneration/RepeatableQuestRewardGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/RepeatableQuestGeneration/RepeatableQuestRewardGenerator.cs @@ -656,7 +656,7 @@ public class RepeatableQuestRewardGenerator( /// If generated Item is found in raid, default True /// Object of "Reward"-item-type protected Reward GeneratePresetReward( - string tpl, + MongoId tpl, int count, int index, List? preset, diff --git a/Libraries/SPTarkov.Server.Core/Helpers/BotGeneratorHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/BotGeneratorHelper.cs index c3380c0e..d3b06214 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/BotGeneratorHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/BotGeneratorHelper.cs @@ -386,7 +386,7 @@ public class BotGeneratorHelper( /// false if no incompatibilities, also has incompatibility reason public ChooseRandomCompatibleModResult IsItemIncompatibleWithCurrentItems( List itemsEquipped, - string tplToCheck, + MongoId tplToCheck, string equipmentSlot ) { @@ -817,7 +817,7 @@ public class BotGeneratorHelper( /// Items sub-grid we want to place item inside /// Item tpl being placed /// True if allowed - protected bool ItemAllowedInContainer(Grid? slotGrid, string? itemTpl) + protected bool ItemAllowedInContainer(Grid? slotGrid, MongoId itemTpl) { var propFilters = slotGrid?.Props?.Filters; var excludedFilter = propFilters?.FirstOrDefault()?.ExcludedFilter ?? []; diff --git a/Libraries/SPTarkov.Server.Core/Helpers/HandbookHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/HandbookHelper.cs index 468f2a86..224a27f7 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/HandbookHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/HandbookHelper.cs @@ -1,4 +1,5 @@ using SPTarkov.DI.Annotations; +using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Models.Eft.Common.Tables; using SPTarkov.Server.Core.Models.Enums; using SPTarkov.Server.Core.Models.Spt.Config; @@ -88,7 +89,7 @@ public class HandbookHelper( /// /// Item tpl to look up price for /// price in roubles - public double GetTemplatePrice(string tpl) + public double GetTemplatePrice(MongoId tpl) { if (HandbookPriceCache.Items.ById.TryGetValue(tpl, out var itemPrice)) { @@ -211,11 +212,11 @@ public class HandbookHelper( { public LookupItem() { - ById = new Dictionary(); + ById = new Dictionary(); ByParent = new Dictionary>(); } - public Dictionary ById { get; set; } + public Dictionary ById { get; set; } public Dictionary> ByParent { get; set; } } diff --git a/Libraries/SPTarkov.Server.Core/Helpers/ItemHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/ItemHelper.cs index a1d9ea2c..2c03c231 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/ItemHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/ItemHelper.cs @@ -57,7 +57,7 @@ public class ItemHelper( nameof(EquipmentSlots.Scabbard), ]; - protected static readonly FrozenSet _dogTagTpls = + protected static readonly FrozenSet _dogTagTpls = [ ItemTpl.BARTER_DOGTAG_BEAR, ItemTpl.BARTER_DOGTAG_BEAR_EOD, @@ -111,7 +111,7 @@ public class ItemHelper( /// Item to look for /// OPTIONAL - slotId of desired item /// True if pool contains item - public bool HasItemWithTpl(IEnumerable itemPool, string itemTpl, string slotId = "") + public bool HasItemWithTpl(IEnumerable itemPool, MongoId itemTpl, string slotId = "") { // Filter the pool by slotId if provided var filteredPool = string.IsNullOrEmpty(slotId) @@ -442,7 +442,7 @@ public class ItemHelper( /// /// Item to look price up of /// Price in roubles - public double? GetItemPrice(string tpl) + public double? GetItemPrice(MongoId tpl) { var handbookPrice = GetStaticItemPrice(tpl); if (handbookPrice >= 1) @@ -459,7 +459,7 @@ public class ItemHelper( /// /// Item to look price up of /// Price in roubles - public double GetItemMaxPrice(string tpl) + public double GetItemMaxPrice(MongoId tpl) { var staticPrice = GetStaticItemPrice(tpl); var dynamicPrice = GetDynamicItemPrice(tpl); @@ -472,7 +472,7 @@ public class ItemHelper( /// /// Items tpl id to look up price /// Price in roubles (0 if not found) - public double GetStaticItemPrice(string tpl) + public double GetStaticItemPrice(MongoId tpl) { var handbookPrice = _handbookHelper.GetTemplatePrice(tpl); if (handbookPrice >= 1) @@ -488,7 +488,7 @@ public class ItemHelper( /// /// Items tpl id to look up price /// Price in roubles (undefined if not found) - public double? GetDynamicItemPrice(string tpl) + public double? GetDynamicItemPrice(MongoId tpl) { if (_databaseService.GetPrices().TryGetValue(tpl, out var price)) { @@ -543,7 +543,7 @@ public class ItemHelper( /// /// Id of the item to check /// true if the item is in the database - public bool IsItemInDb(string itemTpl) + public bool IsItemInDb(MongoId itemTpl) { return _databaseService.GetItems().ContainsKey(itemTpl); } @@ -748,7 +748,7 @@ public class ItemHelper( /// /// Template id to check. /// True if it is a dogtag. - public bool IsDogtag(string tpl) + public bool IsDogtag(MongoId tpl) { return _dogTagTpls.Contains(tpl); } @@ -758,7 +758,7 @@ public class ItemHelper( /// /// Item to check. /// True if it can be stacked. - public bool? IsItemTplStackable(string tpl) + public bool? IsItemTplStackable(MongoId tpl) { if (!_databaseService.GetItems().TryGetValue(tpl, out var item)) { @@ -1178,7 +1178,7 @@ public class ItemHelper( /// Items tpl to check parents of /// Tpl values to check if parents of item match /// bool Match found - public bool DoesItemOrParentsIdMatch(string tpl, List tplsToCheck) + public bool DoesItemOrParentsIdMatch(MongoId tpl, List tplsToCheck) { var itemDetails = GetItem(tpl); var itemExists = itemDetails.Key; @@ -2007,7 +2007,7 @@ public class ItemHelper( // Return all tpls from Money enum // Returns string tpls - public List GetMoneyTpls() + public List GetMoneyTpls() { return [Money.ROUBLES, Money.DOLLARS, Money.EUROS, Money.GP]; } @@ -2026,7 +2026,7 @@ public class ItemHelper( ); } - public string? GetItemBaseType(string tpl, bool rootOnly = true) + public string? GetItemBaseType(MongoId tpl, bool rootOnly = true) { var result = GetItem(tpl); if (!result.Key) diff --git a/Libraries/SPTarkov.Server.Core/Helpers/PresetHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/PresetHelper.cs index 3603799f..c4592359 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/PresetHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/PresetHelper.cs @@ -17,9 +17,9 @@ public class PresetHelper(DatabaseService _databaseService, ItemHelper _itemHelp /// /// Preset cache - key = item tpl, value = preset ids /// - protected Dictionary _lookup = new(); + protected Dictionary _lookup = new(); - public void HydratePresetStore(Dictionary input) + public void HydratePresetStore(Dictionary input) { _lookup = input; } @@ -113,7 +113,7 @@ public class PresetHelper(DatabaseService _databaseService, ItemHelper _itemHelp * @param baseClass The BaseClasses enum to check against * @returns True if the preset is of the given base class, false otherwise */ - public bool IsPresetBaseClass(string id, string baseClass) + public bool IsPresetBaseClass(string id, MongoId baseClass) { return IsPreset(id) && _itemHelper.IsOfBaseclass(GetPreset(id).Encyclopedia, baseClass); } @@ -123,7 +123,7 @@ public class PresetHelper(DatabaseService _databaseService, ItemHelper _itemHelp /// /// Tpl id to check /// True if preset exists for tpl - public bool HasPreset(string templateId) + public bool HasPreset(MongoId templateId) { return _lookup.ContainsKey(templateId); } @@ -169,7 +169,7 @@ public class PresetHelper(DatabaseService _databaseService, ItemHelper _itemHelp /// /// Items tpl to get preset for /// null if no default preset, otherwise Preset - public Preset? GetDefaultPreset(string templateId) + public Preset? GetDefaultPreset(MongoId templateId) { // look in main cache for presets for this tpl if (!_lookup.TryGetValue(templateId, out var presetDetails)) @@ -202,7 +202,7 @@ public class PresetHelper(DatabaseService _databaseService, ItemHelper _itemHelp /// /// Preset id to look up /// tpl mongoid - public string GetBaseItemTpl(string presetId) + public MongoId GetBaseItemTpl(MongoId presetId) { if (!_databaseService.GetGlobals().ItemPresets.TryGetValue(presetId, out var preset)) { @@ -225,7 +225,7 @@ public class PresetHelper(DatabaseService _databaseService, ItemHelper _itemHelp /// /// The item template to get the price of /// The price of the given item preset, or base item if no preset exists - public double GetDefaultPresetOrItemPrice(string tpl) + public double GetDefaultPresetOrItemPrice(MongoId tpl) { // Get default preset if it exists var defaultPreset = GetDefaultPreset(tpl); diff --git a/Libraries/SPTarkov.Server.Core/Helpers/RagfairServerHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/RagfairServerHelper.cs index 57264b87..71104365 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/RagfairServerHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/RagfairServerHelper.cs @@ -1,5 +1,6 @@ using SPTarkov.DI.Annotations; using SPTarkov.Server.Core.Extensions; +using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Models.Eft.Common.Tables; using SPTarkov.Server.Core.Models.Enums; using SPTarkov.Server.Core.Models.Spt.Config; @@ -145,7 +146,7 @@ public class RagfairServerHelper( ); } - public int CalculateDynamicStackCount(string tplId, bool isPreset) + public int CalculateDynamicStackCount(MongoId tplId, bool isPreset) { var config = ragfairConfig.Dynamic; diff --git a/Libraries/SPTarkov.Server.Core/Helpers/TraderHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/TraderHelper.cs index 8ad1bc40..13c6a432 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/TraderHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/TraderHelper.cs @@ -526,7 +526,7 @@ public class TraderHelper( /// /// Item to look up highest price for /// highest rouble cost for item - public double GetHighestTraderPriceRouble(string tpl) + public double GetHighestTraderPriceRouble(MongoId tpl) { if (_highestTraderPriceItems is not null) { @@ -580,7 +580,7 @@ public class TraderHelper( /// /// Item to look up best trader sell-to price /// Rouble price - public double GetHighestSellToTraderPrice(string tpl) + public double GetHighestSellToTraderPrice(MongoId tpl) { // Find largest trader price for item var highestPrice = 1d; // Default price diff --git a/Libraries/SPTarkov.Server.Core/Helpers/WeightedRandomHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/WeightedRandomHelper.cs index 6fcaa0a5..1a5701f7 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/WeightedRandomHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/WeightedRandomHelper.cs @@ -1,4 +1,5 @@ using SPTarkov.DI.Annotations; +using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Models.Spt.Helper; using SPTarkov.Server.Core.Models.Utils; using SPTarkov.Server.Core.Services; @@ -111,7 +112,7 @@ public class WeightedRandomHelper( /// Find the greated common divisor of all weights and use it on the passed in dictionary /// /// Values to reduce - public void ReduceWeightValues(IDictionary weightedDict) + public void ReduceWeightValues(IDictionary weightedDict) { // No values, nothing to reduce if (weightedDict.Count == 0) diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Location.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Location.cs index 69234e94..6db6acc5 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Location.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Location.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Utils.Json; namespace SPTarkov.Server.Core.Models.Eft.Common; @@ -147,7 +148,7 @@ public record StaticForced public string ContainerId { get; set; } [JsonPropertyName("itemTpl")] - public string ItemTpl { get; set; } + public MongoId ItemTpl { get; set; } } public record StaticContainerData diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/BotType.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/BotType.cs index da7db594..25a60260 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/BotType.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/BotType.cs @@ -358,7 +358,7 @@ public record GenerationData /// [JsonPropertyName("whitelist")] [JsonConverter(typeof(ArrayToObjectFactoryConverter))] - public Dictionary? Whitelist { get; set; } + public Dictionary? Whitelist { get; set; } } public record GenerationWeightingItems @@ -496,15 +496,15 @@ public record ItemPools [JsonExtensionData] public Dictionary? ExtensionData { get; set; } - public Dictionary? Backpack { get; set; } + public Dictionary? Backpack { get; set; } - public Dictionary? Pockets { get; set; } + public Dictionary? Pockets { get; set; } - public Dictionary? SecuredContainer { get; set; } + public Dictionary? SecuredContainer { get; set; } - public Dictionary? SpecialLoot { get; set; } + public Dictionary? SpecialLoot { get; set; } - public Dictionary? TacticalVest { get; set; } + public Dictionary? TacticalVest { get; set; } } public record BotDbSkills diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/Reward.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/Reward.cs index d391ef12..940a3ebb 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/Reward.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/Reward.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Models.Enums; using SPTarkov.Server.Core.Utils.Json.Converters; @@ -14,7 +15,7 @@ public record Reward public double? Value { get; set; } [JsonPropertyName("id")] - public string? Id { get; set; } + public MongoId Id { get; set; } [JsonPropertyName("type")] [JsonConverter(typeof(JsonStringEnumConverter))] diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Game/GetItemPricesResponse.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Game/GetItemPricesResponse.cs index af324087..2700c82d 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Game/GetItemPricesResponse.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Game/GetItemPricesResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SPTarkov.Server.Core.Models.Common; namespace SPTarkov.Server.Core.Models.Eft.Game; @@ -11,7 +12,7 @@ public record GetItemPricesResponse public double? SupplyNextTime { get; set; } [JsonPropertyName("prices")] - public Dictionary? Prices { get; set; } + public Dictionary? Prices { get; set; } [JsonPropertyName("currencyCourses")] public Dictionary? CurrencyCourses { get; set; } diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Ragfair/GetMarketPriceRequestData.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Ragfair/GetMarketPriceRequestData.cs index 5fe36e90..39724d5a 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Ragfair/GetMarketPriceRequestData.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Ragfair/GetMarketPriceRequestData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Models.Utils; namespace SPTarkov.Server.Core.Models.Eft.Ragfair; @@ -9,5 +10,5 @@ public record GetMarketPriceRequestData : IRequestData public Dictionary? ExtensionData { get; set; } [JsonPropertyName("templateId")] - public string? TemplateId { get; set; } + public MongoId TemplateId { get; set; } } diff --git a/Libraries/SPTarkov.Server.Core/Models/Spt/Bots/BotLootCache.cs b/Libraries/SPTarkov.Server.Core/Models/Spt/Bots/BotLootCache.cs index 81bcc6a2..be9cf5ea 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Spt/Bots/BotLootCache.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Spt/Bots/BotLootCache.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SPTarkov.Server.Core.Models.Common; namespace SPTarkov.Server.Core.Models.Spt.Bots; @@ -8,43 +9,43 @@ public record BotLootCache public Dictionary? ExtensionData { get; set; } [JsonPropertyName("backpackLoot")] - public Dictionary BackpackLoot { get; set; } = []; + public Dictionary BackpackLoot { get; set; } = []; [JsonPropertyName("pocketLoot")] - public Dictionary PocketLoot { get; set; } = []; + public Dictionary PocketLoot { get; set; } = []; [JsonPropertyName("vestLoot")] - public Dictionary VestLoot { get; set; } = []; + public Dictionary VestLoot { get; set; } = []; [JsonPropertyName("secureLoot")] - public Dictionary SecureLoot { get; set; } = []; + public Dictionary SecureLoot { get; set; } = []; [JsonPropertyName("combinedPoolLoot")] - public Dictionary CombinedPoolLoot { get; set; } = []; + public Dictionary CombinedPoolLoot { get; set; } = []; [JsonPropertyName("specialItems")] - public Dictionary SpecialItems { get; set; } = []; + public Dictionary SpecialItems { get; set; } = []; [JsonPropertyName("healingItems")] - public Dictionary HealingItems { get; set; } = []; + public Dictionary HealingItems { get; set; } = []; [JsonPropertyName("drugItems")] - public Dictionary DrugItems { get; set; } = []; + public Dictionary DrugItems { get; set; } = []; [JsonPropertyName("foodItems")] - public Dictionary FoodItems { get; set; } = []; + public Dictionary FoodItems { get; set; } = []; [JsonPropertyName("drinkItems")] - public Dictionary DrinkItems { get; set; } = []; + public Dictionary DrinkItems { get; set; } = []; [JsonPropertyName("currencyItems")] - public Dictionary CurrencyItems { get; set; } = []; + public Dictionary CurrencyItems { get; set; } = []; [JsonPropertyName("stimItems")] - public Dictionary StimItems { get; set; } = []; + public Dictionary StimItems { get; set; } = []; [JsonPropertyName("grenadeItems")] - public Dictionary GrenadeItems { get; set; } = []; + public Dictionary GrenadeItems { get; set; } = []; } public record LootCacheType diff --git a/Libraries/SPTarkov.Server.Core/Models/Spt/Templates/Templates.cs b/Libraries/SPTarkov.Server.Core/Models/Spt/Templates/Templates.cs index 8986b65e..5719a795 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Spt/Templates/Templates.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Spt/Templates/Templates.cs @@ -44,7 +44,7 @@ public record Templates /// Flea prices of items - gathered from online flea market dump /// [JsonPropertyName("prices")] - public Dictionary? Prices { get; set; } + public Dictionary? Prices { get; set; } /// /// Default equipment loadouts that show on main inventory screen diff --git a/Libraries/SPTarkov.Server.Core/Services/BotEquipmentModPoolService.cs b/Libraries/SPTarkov.Server.Core/Services/BotEquipmentModPoolService.cs index 8d13295f..ea26f278 100644 --- a/Libraries/SPTarkov.Server.Core/Services/BotEquipmentModPoolService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/BotEquipmentModPoolService.cs @@ -135,7 +135,7 @@ public class BotEquipmentModPoolService( return pool; } - private bool SetContainsTpl(HashSet itemSet, string tpl) + private bool SetContainsTpl(HashSet itemSet, MongoId tpl) { lock (_lockObject) { @@ -143,7 +143,7 @@ public class BotEquipmentModPoolService( } } - private bool AddTplToSet(HashSet itemSet, string itemToAddTpl) + private bool AddTplToSet(HashSet itemSet, MongoId itemToAddTpl) { lock (_lockObject) { diff --git a/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs b/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs index 45c0ebaf..f5111b35 100644 --- a/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs @@ -48,7 +48,7 @@ public class BotLootCacheService( /// OPTIONAL - item price min and max value filter /// THIS IS NOT A THREAD SAFE METHOD /// dictionary - public Dictionary GetLootFromCache( + public Dictionary GetLootFromCache( string botRole, bool isPmc, string lootType, @@ -68,7 +68,7 @@ public class BotLootCacheService( return []; } - Dictionary result; + Dictionary result; switch (lootType) { case LootCacheType.Special: @@ -175,12 +175,12 @@ public class BotLootCacheService( var lootPool = botJsonTemplate.BotInventory.Items; // Flatten all individual slot loot pools into one big pool, while filtering out potentially missing templates - Dictionary specialLootPool = new(); - Dictionary backpackLootPool = new(); - Dictionary pocketLootPool = new(); - Dictionary vestLootPool = new(); - Dictionary secureLootPool = new(); - Dictionary combinedLootPool = new(); + Dictionary specialLootPool = new(); + Dictionary backpackLootPool = new(); + Dictionary pocketLootPool = new(); + Dictionary vestLootPool = new(); + Dictionary secureLootPool = new(); + Dictionary combinedLootPool = new(); if (isPmc) { @@ -195,7 +195,7 @@ public class BotLootCacheService( } // Backpack/Pockets etc - var poolsToProcess = new Dictionary> + var poolsToProcess = new Dictionary> { { "Backpack", lootPool.Backpack }, { "Pockets", lootPool.Pockets }, @@ -420,7 +420,7 @@ public class BotLootCacheService( ); // lacks width // Get vest loot (excluding magazines, bullets, grenades, medical and healing/stim items) - var filteredVestItems = new Dictionary(); + var filteredVestItems = new Dictionary(); foreach (var itemKvP in vestLootPool) { var itemResult = _itemHelper.GetItem(itemKvP.Key); @@ -480,12 +480,12 @@ public class BotLootCacheService( /// Pool to filter /// Delegate to filter pool by /// - protected Dictionary FilterItemPool( - Dictionary lootPool, + protected Dictionary FilterItemPool( + Dictionary lootPool, Func shouldBeSkipped ) { - var filteredItems = new Dictionary(); + var filteredItems = new Dictionary(); foreach (var (itemTpl, itemWeight) in lootPool) { var (isValidItem, itemTemplate) = _itemHelper.GetItem(itemTpl); @@ -511,9 +511,9 @@ public class BotLootCacheService( /// Weights to return /// Dictionary and should pool be hydrated by items in combined loot pool protected static ( - Dictionary, + Dictionary, bool populateFromCombinedPool - ) GetGenerationWeights(Dictionary? weights) + ) GetGenerationWeights(Dictionary? weights) { var result = weights ?? []; return (result, !result.Any()); // empty dict = should be populated from combined pool @@ -526,8 +526,8 @@ public class BotLootCacheService( /// Dictionary to add item to /// Dictionary of items to add protected void AddItemsToPool( - Dictionary poolToAddTo, - Dictionary poolOfItemsToAdd + Dictionary poolToAddTo, + Dictionary poolOfItemsToAdd ) { foreach (var (tpl, weight) in poolOfItemsToAdd) @@ -577,17 +577,17 @@ public class BotLootCacheService( return props.ThrowType is not null; } - protected bool IsFood(string tpl) + protected bool IsFood(MongoId tpl) { return _itemHelper.IsOfBaseclass(tpl, BaseClasses.FOOD); } - protected bool IsDrink(string tpl) + protected bool IsDrink(MongoId tpl) { return _itemHelper.IsOfBaseclass(tpl, BaseClasses.DRINK); } - protected bool IsCurrency(string tpl) + protected bool IsCurrency(MongoId tpl) { return _itemHelper.IsOfBaseclass(tpl, BaseClasses.MONEY); } diff --git a/Libraries/SPTarkov.Server.Core/Services/DatabaseService.cs b/Libraries/SPTarkov.Server.Core/Services/DatabaseService.cs index 332e9292..da345319 100644 --- a/Libraries/SPTarkov.Server.Core/Services/DatabaseService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/DatabaseService.cs @@ -280,7 +280,7 @@ public class DatabaseService( } /// assets/database/templates/prices.json - public Dictionary GetPrices() + public Dictionary GetPrices() { if (_databaseServer.GetTables().Templates?.Prices == null) { diff --git a/Libraries/SPTarkov.Server.Core/Services/FenceService.cs b/Libraries/SPTarkov.Server.Core/Services/FenceService.cs index d923147e..cf9c1f77 100644 --- a/Libraries/SPTarkov.Server.Core/Services/FenceService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/FenceService.cs @@ -1012,7 +1012,7 @@ public class FenceService( return ItemInPreventDupeCategoryList(itemDbDetails.Id); } - protected bool ItemInPreventDupeCategoryList(string tpl) + protected bool ItemInPreventDupeCategoryList(MongoId tpl) { // Item type in config list return itemHelper.IsOfBaseclasses(tpl, traderConfig.Fence.PreventDuplicateOffersOfCategory); diff --git a/Libraries/SPTarkov.Server.Core/Services/ItemFilterService.cs b/Libraries/SPTarkov.Server.Core/Services/ItemFilterService.cs index fcc81b32..6384cb31 100644 --- a/Libraries/SPTarkov.Server.Core/Services/ItemFilterService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/ItemFilterService.cs @@ -27,7 +27,7 @@ public class ItemFilterService( /// /// Template id /// True if blacklisted - public bool ItemBlacklisted(string tpl) + public bool ItemBlacklisted(MongoId tpl) { if (_itemBlacklistCache.Count == 0) { @@ -42,7 +42,7 @@ public class ItemFilterService( /// /// Item tpl to check is on blacklist /// True when blacklisted - public bool ItemRewardBlacklisted(string tpl) + public bool ItemRewardBlacklisted(MongoId tpl) { return _itemConfig.RewardItemBlacklist.Contains(tpl); } @@ -88,7 +88,7 @@ public class ItemFilterService( /// /// template id /// True if boss item - public bool BossItem(string tpl) + public bool BossItem(MongoId tpl) { return _itemConfig.BossItems.Contains(tpl); } @@ -107,7 +107,7 @@ public class ItemFilterService( /// /// Template id /// True if blacklisted - public bool IsLootableItemBlacklisted(string itemKey) + public bool IsLootableItemBlacklisted(MongoId itemKey) { if (!_lootableItemBlacklistCache.Any()) { @@ -117,7 +117,7 @@ public class ItemFilterService( return _lootableItemBlacklistCache.Contains(itemKey); } - public bool IsItemBlacklisted(string tpl) + public bool IsItemBlacklisted(MongoId tpl) { if (!_itemBlacklistCache.Any()) { @@ -148,7 +148,7 @@ public class ItemFilterService( /// /// Template id /// True if boss item - public bool IsBossItem(string tpl) + public bool IsBossItem(MongoId tpl) { return _itemConfig.BossItems.Contains(tpl); } @@ -158,7 +158,7 @@ public class ItemFilterService( /// /// Item tpl to check is on blacklist /// true when blacklisted - public bool IsItemRewardBlacklisted(string tpl) + public bool IsItemRewardBlacklisted(MongoId tpl) { return _itemConfig.RewardItemBlacklist.Contains(tpl); } diff --git a/Libraries/SPTarkov.Server.Core/Services/RagfairOfferService.cs b/Libraries/SPTarkov.Server.Core/Services/RagfairOfferService.cs index 55d2f122..453443b5 100644 --- a/Libraries/SPTarkov.Server.Core/Services/RagfairOfferService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/RagfairOfferService.cs @@ -42,12 +42,12 @@ public class RagfairOfferService( return ragfairOfferHolder.GetOffers(); } - public RagfairOffer? GetOfferByOfferId(string offerId) + public RagfairOffer? GetOfferByOfferId(MongoId offerId) { return ragfairOfferHolder.GetOfferById(offerId); } - public List? GetOffersOfType(string templateId) + public List? GetOffersOfType(MongoId templateId) { return ragfairOfferHolder.GetOffersByTemplate(templateId); } diff --git a/Libraries/SPTarkov.Server.Core/Services/RagfairPriceService.cs b/Libraries/SPTarkov.Server.Core/Services/RagfairPriceService.cs index b38c2d87..e3090dea 100644 --- a/Libraries/SPTarkov.Server.Core/Services/RagfairPriceService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/RagfairPriceService.cs @@ -29,7 +29,7 @@ public class RagfairPriceService( ) { private readonly RagfairConfig _ragfairConfig = _configServer.GetConfig(); - protected Dictionary? _staticPrices; + protected Dictionary? _staticPrices; /// /// Generate static (handbook) and dynamic (prices.json) flea prices, store inside class as dictionaries @@ -50,7 +50,7 @@ public class RagfairPriceService( /// public void RefreshStaticPrices() { - _staticPrices = new Dictionary(); + _staticPrices = new Dictionary(); foreach ( var item in _databaseService .GetItems() @@ -77,9 +77,9 @@ public class RagfairPriceService( /// /// Item tpl id to get price for /// price in roubles - public double GetFleaPriceForItem(string tplId) + public double GetFleaPriceForItem(MongoId tplId) { - // Get dynamic price (templates/prices), if that doesnt exist get price from static array (templates/handbook) + // Get dynamic price (templates/prices), if that doesn't exist get price from static array (templates/handbook) var itemPrice = _itemHelper.GetDynamicItemPrice(tplId) ?? GetStaticPriceForItem(tplId); if (itemPrice is null) { @@ -122,7 +122,7 @@ public class RagfairPriceService( /// /// Item template id to look up /// Price in roubles - public double? GetDynamicPriceForItem(string itemTpl) + public double? GetDynamicPriceForItem(MongoId itemTpl) { _databaseService.GetPrices().TryGetValue(itemTpl, out var value); @@ -134,7 +134,7 @@ public class RagfairPriceService( /// /// item template id to look up /// price in roubles - public double? GetStaticPriceForItem(string itemTpl) + public double? GetStaticPriceForItem(MongoId itemTpl) { return _handbookHelper.GetTemplatePrice(itemTpl); } @@ -144,7 +144,7 @@ public class RagfairPriceService( /// This will refresh the caches prior to building the output /// /// Dictionary of item tpls and rouble cost - public Dictionary GetAllFleaPrices() + public Dictionary GetAllFleaPrices() { var dynamicPrices = _databaseService.GetPrices(); // Use dynamic prices first, fill in any gaps with data from static prices (handbook) @@ -154,7 +154,7 @@ public class RagfairPriceService( .ToDictionary(x => x.Key, x => x.First().Value); } - public Dictionary GetAllStaticPrices() + public Dictionary GetAllStaticPrices() { // Refresh the cache so we include any newly added custom items if (_staticPrices is null) @@ -251,10 +251,10 @@ public class RagfairPriceService( /// /// public double? GetDynamicItemPrice( - string itemTemplateId, + MongoId itemTemplateId, string desiredCurrency, - Item item = null, - List offerItems = null, + Item? item = null, + List? offerItems = null, bool? isPackOffer = null ) { diff --git a/Libraries/SPTarkov.Server.Core/Services/RagfairRequiredItemsService.cs b/Libraries/SPTarkov.Server.Core/Services/RagfairRequiredItemsService.cs index 3ad94a2b..eb633264 100644 --- a/Libraries/SPTarkov.Server.Core/Services/RagfairRequiredItemsService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/RagfairRequiredItemsService.cs @@ -1,6 +1,7 @@ using System.Collections.Concurrent; using SPTarkov.DI.Annotations; using SPTarkov.Server.Core.Helpers; +using SPTarkov.Server.Core.Models.Common; namespace SPTarkov.Server.Core.Services; @@ -13,14 +14,14 @@ public class RagfairRequiredItemsService( /// /// Key = tpl /// - protected readonly ConcurrentDictionary> _requiredItemsCache = new(); + protected readonly ConcurrentDictionary> _requiredItemsCache = new(); /// /// Get the offerId of offers that require the supplied tpl /// /// Tpl to find offers ids for /// - public HashSet GetRequiredOffersById(string tpl) + public HashSet GetRequiredOffersById(MongoId tpl) { if (_requiredItemsCache.TryGetValue(tpl, out var offerIds)) { diff --git a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs index 18361e0c..963bce7f 100644 --- a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs @@ -392,7 +392,7 @@ public class SeasonalEventService( StringComparison.OrdinalIgnoreCase ) ); - var prop = (Dictionary?)propInfo.GetValue(botInventory.Items); + var prop = (Dictionary?)propInfo.GetValue(botInventory.Items); if (prop is null) { diff --git a/Libraries/SPTarkov.Server.Core/Utils/RagfairOfferHolder.cs b/Libraries/SPTarkov.Server.Core/Utils/RagfairOfferHolder.cs index ab3778b5..52b844f2 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/RagfairOfferHolder.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/RagfairOfferHolder.cs @@ -27,17 +27,17 @@ public class RagfairOfferHolder( /// /// Ragfair offer cache, keyed by offer Id /// - private readonly ConcurrentDictionary _offersById = new(); + private readonly ConcurrentDictionary _offersById = new(); /// /// Offer Ids keyed by tpl /// - private readonly ConcurrentDictionary> _offersByTemplate = new(); + private readonly ConcurrentDictionary> _offersByTemplate = new(); /// /// Offer ids keyed by trader Id /// - private readonly ConcurrentDictionary> _offersByTrader = new(); + private readonly ConcurrentDictionary> _offersByTrader = new(); private readonly Lock _expiredOfferIdsLock = new(); private readonly Lock _ragfairOperationLock = new(); @@ -47,7 +47,7 @@ public class RagfairOfferHolder( /// /// Ragfair offer id /// RagfairOffer - public RagfairOffer? GetOfferById(string id) + public RagfairOffer? GetOfferById(MongoId id) { return _offersById.GetValueOrDefault(id); }