Converted more ids to MongoId

This commit is contained in:
Chomp
2025-07-05 12:35:03 +01:00
parent 69e71e0820
commit 4f5571c2d4
44 changed files with 144 additions and 114 deletions
@@ -161,7 +161,7 @@ public class InventoryController(
if (itemToAdjust is null)
{
_logger.Error(
$"Unable find item: {request.Item} to: {request.State} on player {sessionId}to: "
$"Unable find item: {request.Item.Value.ToString()} to: {request.State} on player: {sessionId} to: "
);
return;
@@ -286,16 +286,16 @@ namespace SPTarkov.Server.Core.Extensions
/// <returns>list of Item objects</returns>
public static List<Item> FindAndReturnChildrenAsItems(
this IEnumerable<Item> items,
string baseItemId,
MongoId baseItemId,
bool modsOnly = false
)
{
// Use dictionary to make key lookup faster, convert to list before being returned
OrderedDictionary<string, Item> result = [];
OrderedDictionary<MongoId, Item> result = [];
foreach (var childItem in items)
{
// Include itself
if (string.Equals(childItem.Id, baseItemId, StringComparison.Ordinal))
if (childItem.Id == baseItemId)
{
// Root item MUST be at 0 index for things like flea market offers
result.Insert(0, childItem.Id, childItem);
@@ -311,7 +311,8 @@ namespace SPTarkov.Server.Core.Extensions
// Items parentId matches root item AND returned items doesn't contain current child
if (
!result.ContainsKey(childItem.Id)
&& string.Equals(childItem.ParentId, baseItemId, StringComparison.Ordinal)
&& childItem.ParentId != "hideout"
&& childItem.ParentId == baseItemId
)
{
foreach (var item in FindAndReturnChildrenAsItems(items, childItem.Id))
@@ -1,4 +1,5 @@
using SPTarkov.Server.Core.Models.Eft.Common;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Common;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
using SPTarkov.Server.Core.Models.Enums;
@@ -125,7 +126,7 @@ namespace SPTarkov.Server.Core.Extensions
return pmcData.IsParentInStash(itemToCheck.Id);
}
public static bool IsParentInStash(this PmcData pmcData, string itemId)
public static bool IsParentInStash(this PmcData pmcData, MongoId itemId)
{
// Item not found / has no parent
var item = pmcData.Inventory.Items.FirstOrDefault(item => item.Id == itemId);
@@ -1,4 +1,5 @@
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
namespace SPTarkov.Server.Core.Extensions
{
@@ -14,7 +15,7 @@ namespace SPTarkov.Server.Core.Extensions
/// <returns>Modified assort</returns>
public static TraderAssort RemoveItemFromAssort(
this TraderAssort assort,
string itemId,
MongoId itemId,
bool isFlea = false
)
{
@@ -84,6 +84,17 @@ public class BotEquipmentModGenerator(
"cartridges",
];
const string modRecieverKey = "mod_reciever";
const string modMount001Key = "mod_mount_001";
const string modGasBlockKey = "mod_gas_block";
const string modPistolGrip = "mod_pistol_grip";
const string modStockKey = "mod_stock";
const string modBarrelKey = "mod_barrel";
const string modHandguardKey = "mod_handguard";
const string modMountKey = "mod_mount";
const string modScopeKey = "mod_scope";
const string modScope000Key = "mod_scope_000";
protected readonly BotConfig _botConfig = _configServer.GetConfig<BotConfig>();
/// <summary>
@@ -186,7 +197,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(
@@ -929,7 +941,7 @@ public class BotEquipmentModGenerator(
/// <returns>Sorted array</returns>
public HashSet<string> SortModKeys(
HashSet<string> unsortedSlotKeys,
string itemTplWithKeysToSort
MongoId itemTplWithKeysToSort
)
{
// No need to sort with only 1 item in array
@@ -941,16 +953,6 @@ public class BotEquipmentModGenerator(
var isMount = _itemHelper.IsOfBaseclass(itemTplWithKeysToSort, BaseClasses.MOUNT);
HashSet<string> sortedKeys = [];
const string modRecieverKey = "mod_reciever";
const string modMount001Key = "mod_mount_001";
const string modGasBlockKey = "mod_gas_block";
const string modPistolGrip = "mod_pistol_grip";
const string modStockKey = "mod_stock";
const string modBarrelKey = "mod_barrel";
const string modHandguardKey = "mod_handguard";
const string modMountKey = "mod_mount";
const string modScopeKey = "mod_scope";
const string modScope000Key = "mod_scope_000";
// Mounts are a special case, they need scopes first before more mounts
if (isMount)
@@ -645,7 +645,7 @@ public class BotInventoryGenerator(
/// <param name="equipmentBlacklist">Blacklist to filter mod pool with</param>
/// <returns>Filtered pool of mods</returns>
public Dictionary<string, HashSet<MongoId>> GetFilteredDynamicModsForItem(
string itemTpl,
MongoId itemTpl,
Dictionary<string, HashSet<MongoId>> equipmentBlacklist
)
{
@@ -394,7 +394,7 @@ public class CompletionQuestGenerator(
/// <param name="completionConfig">Completion config from quest.json</param>
/// <returns>object of "Completion"-condition</returns>
protected QuestCondition GenerateCondition(
string itemTpl,
MongoId itemTpl,
double value,
Completion completionConfig
)
@@ -818,7 +818,7 @@ public class RepeatableQuestRewardGenerator(
/// <param name="itemBaseWhitelist"> Default null, specific trader item base classes</param>
/// <returns> True if item is valid reward </returns>
public bool IsValidRewardItem(
string tpl,
MongoId tpl,
HashSet<MongoId> itemTplBlacklist,
HashSet<MongoId> itemTypeBlacklist,
List<MongoId>? itemBaseWhitelist = null
@@ -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.Eft.Profile;
using SPTarkov.Server.Core.Models.Utils;
@@ -46,7 +47,7 @@ public class DialogueHelper(ISptLogger<DialogueHelper> logger, ProfileHelper pro
/// <param name="sessionID">Session/player id</param>
/// <param name="itemId">Item being moved to inventory</param>
/// <returns>Collection of items from message</returns>
public List<Item> GetMessageItemContents(string messageID, string sessionID, string itemId)
public List<Item> GetMessageItemContents(string messageID, string sessionID, MongoId itemId)
{
var fullProfile = profileHelper.GetFullProfile(sessionID);
var dialogueData = fullProfile.DialogueRecords;
@@ -65,23 +65,27 @@ public class InRaidHelper(
var insured = _cloner.Clone(serverProfile.InsuredItems);
// Remove equipment and loot items stored on player from server profile in preparation for data from client being added
_inventoryHelper.RemoveItem(serverProfile, serverProfile.Inventory.Equipment, sessionID);
_inventoryHelper.RemoveItem(
serverProfile,
serverProfile.Inventory.Equipment.Value,
sessionID
);
// Remove quest items stored on player from server profile in preparation for data from client being added
_inventoryHelper.RemoveItem(
serverProfile,
serverProfile.Inventory.QuestRaidItems,
serverProfile.Inventory.QuestRaidItems.Value,
sessionID
);
// Get all items that have a parent of `serverProfile.Inventory.equipment` (All items player had on them at end of raid)
var postRaidInventoryItems = postRaidProfile.Inventory.Items.FindAndReturnChildrenAsItems(
postRaidProfile.Inventory.Equipment
postRaidProfile.Inventory.Equipment.Value
);
// Get all items that have a parent of `serverProfile.Inventory.questRaidItems` (Quest items player had on them at end of raid)
var postRaidQuestItems = postRaidProfile.Inventory.Items.FindAndReturnChildrenAsItems(
postRaidProfile.Inventory.QuestRaidItems
postRaidProfile.Inventory.QuestRaidItems.Value
);
// Handle Removing of FIR status if player did not survive + not transferring
@@ -480,12 +480,12 @@ public class InventoryHelper(
/// <param name="output">OPTIONAL - ItemEventRouterResponse</param>
public void RemoveItem(
PmcData profile,
string? itemId,
MongoId itemId,
string sessionId,
ItemEventRouterResponse? output = null
)
{
if (itemId is null)
if (itemId.IsEmpty())
{
_logger.Warning(
_serverLocalisationService.GetText("inventory-unable_to_remove_item_no_id_given")
@@ -617,13 +617,13 @@ public class InventoryHelper(
/// <returns>ItemEventRouterResponse</returns>
public ItemEventRouterResponse RemoveItemByCount(
PmcData pmcData,
string? itemId,
MongoId itemId,
int countToRemove,
string sessionId,
ItemEventRouterResponse? output
)
{
if (itemId is null)
if (itemId.IsEmpty())
{
return output;
}
@@ -992,12 +992,12 @@ public class InventoryHelper(
/// Based on the item action, determine whose inventories we should be looking at for from and to.
/// </summary>
/// <param name="request">Item interaction request</param>
/// <param name="item">Item being moved/split/etc to inventory</param>
/// <param name="itemId">Item being moved/split/etc to inventory</param>
/// <param name="sessionId">Session id / players Id</param>
/// <returns>OwnerInventoryItems with inventory of player/scav to adjust</returns>
public OwnerInventoryItems GetOwnerInventoryItems(
InventoryBaseActionRequestData request,
string? item,
MongoId itemId,
string sessionId
)
{
@@ -1021,7 +1021,7 @@ public class InventoryHelper(
fromInventoryItems = _dialogueHelper.GetMessageItemContents(
request.FromOwner.Id,
sessionId,
item
itemId
);
fromType = "mail";
}
@@ -1356,7 +1356,7 @@ public class InventoryHelper(
/// </summary>
/// <param name="itemTpl">Container being opened</param>
/// <returns>Reward details</returns>
public RewardDetails? GetRandomLootContainerRewardDetails(string itemTpl)
public RewardDetails? GetRandomLootContainerRewardDetails(MongoId itemTpl)
{
_inventoryConfig.RandomLootContainers.TryGetValue(itemTpl, out var result);
@@ -339,7 +339,7 @@ public class ItemHelper(
/// </summary>
/// <param name="itemTpl">Armor item</param>
/// <returns>True if item needs some kind of insert</returns>
public bool ArmorItemHasRemovableOrSoftInsertSlots(string itemTpl)
public bool ArmorItemHasRemovableOrSoftInsertSlots(MongoId itemTpl)
{
if (!ArmorItemCanHoldMods(itemTpl))
{
@@ -354,7 +354,7 @@ public class ItemHelper(
/// </summary>
/// <param name="itemTpl">Item tpl to check for plate support</param>
/// <returns>True when armor can hold plates</returns>
public bool ArmorItemHasRemovablePlateSlots(string itemTpl)
public bool ArmorItemHasRemovablePlateSlots(MongoId itemTpl)
{
var itemTemplate = GetItem(itemTpl);
@@ -368,7 +368,7 @@ public class ItemHelper(
/// </summary>
/// <param name="itemTpl">Item tpl to check</param>
/// <returns>True if it needs armor inserts</returns>
public bool ItemRequiresSoftInserts(string itemTpl)
public bool ItemRequiresSoftInserts(MongoId itemTpl)
{
// Not a slot that takes soft-inserts
if (!ArmorItemCanHoldMods(itemTpl))
@@ -717,7 +717,7 @@ public class ItemHelper(
/// <param name="itemIdToFind">Template id of item to check for</param>
/// <param name="assort">List of items to check in</param>
/// <returns>List of children of requested item</returns>
public List<Item> FindAndReturnChildrenByAssort(string itemIdToFind, List<Item> assort)
public List<Item> FindAndReturnChildrenByAssort(MongoId itemIdToFind, List<Item> assort)
{
List<Item> list = [];
foreach (var itemFromAssort in assort)
@@ -1263,7 +1263,7 @@ public class ItemHelper(
/// <param name="itemId">The unique identifier of the item for which to find the main parent.</param>
/// <param name="itemsMap">A Dictionary containing item IDs mapped to their corresponding Item objects for quick lookup.</param>
/// <returns>The Item object representing the top-most parent of the given item, or null if no such parent exists.</returns>
public Item? GetAttachmentMainParent(string itemId, Dictionary<MongoId, Item> itemsMap)
public Item? GetAttachmentMainParent(MongoId itemId, Dictionary<MongoId, Item> itemsMap)
{
var currentItem = itemsMap.FirstOrDefault(x => x.Key == itemId).Value;
@@ -1309,7 +1309,7 @@ public class ItemHelper(
/// <param name="itemId">The unique identifier of the item for which to find the equipment parent.</param>
/// <param name="itemsMap">A Dictionary containing item IDs mapped to their corresponding Item objects for quick lookup.</param>
/// <returns>The Item object representing the equipment parent of the given item, or `null` if no such parent exists</returns>
public Item? GetEquipmentParent(string itemId, Dictionary<string, Item> itemsMap)
public Item? GetEquipmentParent(MongoId itemId, Dictionary<MongoId, Item> itemsMap)
{
var currentItem = itemsMap.GetValueOrDefault(itemId);
@@ -1731,7 +1731,7 @@ public class ItemHelper(
/// </summary>
/// <param name="itemTpl">Tpl of item to get name of</param>
/// <returns>Full name, short name if not found</returns>
public string GetItemName(string itemTpl)
public string GetItemName(MongoId itemTpl)
{
var localeDb = _localeService.GetLocaleDb();
var result = localeDb[$"{itemTpl} Name"];
@@ -2,6 +2,7 @@ using System.Globalization;
using SPTarkov.Common.Extensions;
using SPTarkov.DI.Annotations;
using SPTarkov.Server.Core.Extensions;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Common;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
using SPTarkov.Server.Core.Models.Eft.ItemEvent;
@@ -623,7 +624,7 @@ public class QuestHelper(
/// <param name="output">ItemEvent router response</param>
public void ChangeItemStack(
PmcData pmcData,
string itemId,
MongoId itemId,
int newStackSize,
string sessionID,
ItemEventRouterResponse output
@@ -1010,8 +1011,8 @@ public class QuestHelper(
/// <param name="allQuests">All quests to check</param>
/// <returns>quest id with 'FindItem' condition id</returns>
public Dictionary<string, string> GetFindItemConditionByQuestItem(
string itemTpl,
string[] questIds,
MongoId itemTpl,
MongoId[] questIds,
List<Quest> allQuests
)
{
@@ -881,7 +881,7 @@ public class RagfairOfferHelper(
* @param boughtAmount How many were purchased
* @returns Localised message text
*/
protected string GetLocalisedOfferSoldMessage(string itemTpl, int boughtAmount)
protected string GetLocalisedOfferSoldMessage(MongoId itemTpl, int boughtAmount)
{
// Generate a message to inform that item was sold
var globalLocales = _localeService.GetLocaleDb();
@@ -896,7 +896,7 @@ public class RagfairOfferHelper(
}
// Used to replace tokens in sold message sent to player
var messageKey = $"{itemTpl} Name";
var messageKey = $"{itemTpl.ToString()} Name";
var hasKey = globalLocales.TryGetValue(messageKey, out var value);
var tplVars = new SystemData
@@ -99,7 +99,7 @@ public class RagfairServerHelper(
* @param itemTemplateId Item tpl to check is blacklisted
* @returns True if its blacklisted
*/
protected bool IsItemOnCustomFleaBlacklist(string itemTemplateId)
protected bool IsItemOnCustomFleaBlacklist(MongoId itemTemplateId)
{
return ragfairConfig.Dynamic.Blacklist.Custom.Contains(itemTemplateId);
}
@@ -1,6 +1,7 @@
using System.Text.RegularExpressions;
using SPTarkov.DI.Annotations;
using SPTarkov.Server.Core.Extensions;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Common;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
using SPTarkov.Server.Core.Models.Eft.Inventory;
@@ -414,7 +415,7 @@ public record PurchaseDetails
public record PurchaseItems
{
public string ItemId { get; set; }
public MongoId ItemId { get; set; }
public double Count { get; set; }
}
@@ -11,7 +11,7 @@ public record IdWithCount
/// ID of stack to take money from
/// </summary>
[JsonPropertyName("id")]
public string? Id { get; set; }
public MongoId Id { get; set; }
/// <summary>
/// Amount of money to take off player for treatment
@@ -571,7 +571,7 @@ public record DroppedItem
public string? QuestId { get; set; }
public string? ItemId { get; set; }
public MongoId? ItemId { get; set; }
public string? ZoneId { get; set; }
}
@@ -583,7 +583,7 @@ public record FoundInRaidItem
public string? QuestId { get; set; }
public string? ItemId { get; set; }
public MongoId? ItemId { get; set; }
}
public record Victim
@@ -21,7 +21,7 @@ public record Quest
/// _id
/// </summary>
[JsonPropertyName("_id")]
public required string Id { get; set; }
public required MongoId Id { get; set; }
[JsonPropertyName("canShowNotificationsInGame")]
public required bool CanShowNotificationsInGame { get; set; }
@@ -145,7 +145,7 @@ public record QuestStatus
public Dictionary<string, object>? ExtensionData { get; set; }
[JsonPropertyName("qid")]
public required string QId { get; set; }
public required MongoId QId { get; set; }
[JsonPropertyName("startTime")]
public required double StartTime { get; set; }
@@ -260,10 +260,10 @@ public record TraderAssort
public List<Item>? Items { get; set; }
[JsonPropertyName("barter_scheme")]
public Dictionary<string, List<List<BarterScheme>>>? BarterScheme { get; set; }
public Dictionary<MongoId, List<List<BarterScheme>>>? BarterScheme { get; set; }
[JsonPropertyName("loyal_level_items")]
public Dictionary<string, int>? LoyalLevelItems { get; set; }
public Dictionary<MongoId, int>? LoyalLevelItems { get; set; }
}
public record BarterScheme
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Inventory;
namespace SPTarkov.Server.Core.Models.Eft.Health;
@@ -9,7 +10,7 @@ public record OffraidEatRequestData : InventoryBaseActionRequestData
public Dictionary<string, object>? ExtensionData { get; set; }
[JsonPropertyName("item")]
public string? Item { get; set; }
public MongoId Item { get; set; }
[JsonPropertyName("count")]
public int? Count { get; set; }
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Inventory;
namespace SPTarkov.Server.Core.Models.Eft.Health;
@@ -9,7 +10,7 @@ public record OffraidHealRequestData : InventoryBaseActionRequestData
public Dictionary<string, object>? ExtensionData { get; set; }
[JsonPropertyName("item")]
public string? Item { get; set; }
public MongoId Item { get; set; }
[JsonPropertyName("part")]
public string? Part { get; set; }
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
namespace SPTarkov.Server.Core.Models.Eft.Hideout;
@@ -39,7 +40,7 @@ public record HideoutCustomisationGlobal
public bool? IsEnabled { get; set; }
[JsonPropertyName("itemId")]
public string? ItemId { get; set; }
public MongoId? ItemId { get; set; }
}
public record HideoutCustomisationSlot
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
namespace SPTarkov.Server.Core.Models.Eft.Inventory;
@@ -29,5 +30,5 @@ public record ItemToAdd
public bool? IsPreset { get; set; }
[JsonPropertyName("item_id")]
public string? ItemId { get; set; }
public MongoId? ItemId { get; set; }
}
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
namespace SPTarkov.Server.Core.Models.Eft.Inventory;
@@ -8,7 +9,7 @@ public record InventoryAddRequestData : InventoryBaseActionRequestData
public Dictionary<string, object>? ExtensionData { get; set; }
[JsonPropertyName("item")]
public string? Item { get; set; }
public MongoId? Item { get; set; }
[JsonPropertyName("container")]
public Container? Container { get; set; }
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
namespace SPTarkov.Server.Core.Models.Eft.Inventory;
@@ -8,7 +9,7 @@ public record InventoryBindRequestData : InventoryBaseActionRequestData
public Dictionary<string, object>? ExtensionData { get; set; }
[JsonPropertyName("item")]
public string? Item { get; set; }
public MongoId Item { get; set; }
[JsonPropertyName("index")]
public string? Index { get; set; }
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
namespace SPTarkov.Server.Core.Models.Eft.Inventory;
@@ -9,7 +10,7 @@ public record InventoryCreateMarkerRequestData : InventoryBaseActionRequestData
public Dictionary<string, object>? ExtensionData { get; set; }
[JsonPropertyName("item")]
public string? Item { get; set; }
public MongoId? Item { get; set; }
[JsonPropertyName("mapMarker")]
public MapMarker? MapMarker { get; set; }
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
namespace SPTarkov.Server.Core.Models.Eft.Inventory;
@@ -8,7 +9,7 @@ public record InventoryDeleteMarkerRequestData : InventoryBaseActionRequestData
public Dictionary<string, object>? ExtensionData { get; set; }
[JsonPropertyName("item")]
public string? Item { get; set; }
public MongoId? Item { get; set; }
[JsonPropertyName("X")]
public int? X { get; set; }
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
namespace SPTarkov.Server.Core.Models.Eft.Inventory;
@@ -9,7 +10,7 @@ public record InventoryEditMarkerRequestData : InventoryBaseActionRequestData
public Dictionary<string, object>? ExtensionData { get; set; }
[JsonPropertyName("item")]
public string? Item { get; set; }
public MongoId? Item { get; set; }
[JsonPropertyName("X")]
public double? X { get; set; }
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
namespace SPTarkov.Server.Core.Models.Eft.Inventory;
@@ -12,7 +13,7 @@ public record PinOrLockItemRequest : InventoryBaseActionRequestData
/// Id of item being pinned
/// </summary>
[JsonPropertyName("Item")]
public string? Item { get; set; }
public MongoId? Item { get; set; }
/// <summary>
/// "Pinned"/"Locked"/"Free"
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Common.Request;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
using SPTarkov.Server.Core.Models.Utils;
@@ -29,7 +30,7 @@ public record Daum
public string? Action { get; set; }
[JsonPropertyName("item")]
public string? Item { get; set; }
public MongoId? Item { get; set; }
[JsonPropertyName("items")]
public List<Item>? Items { get; set; }
@@ -6,7 +6,7 @@ namespace SPTarkov.Server.Core.Models.Eft.Trade;
public record ProcessBuyTradeRequestData : ProcessBaseTradeRequestData
{
[JsonPropertyName("item_id")]
public string? ItemId { get; set; }
public MongoId ItemId { get; set; }
[JsonPropertyName("count")]
public int? Count { get; set; }
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Inventory;
namespace SPTarkov.Server.Core.Models.Eft.Wishlist;
@@ -9,7 +10,7 @@ public record ChangeWishlistItemCategoryRequest : InventoryBaseActionRequestData
public Dictionary<string, object>? ExtensionData { get; set; }
[JsonPropertyName("item")]
public string? Item { get; set; }
public MongoId Item { get; set; }
[JsonPropertyName("category")]
public int? Category { get; set; }
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
namespace SPTarkov.Server.Core.Models.Spt.Fence;
@@ -12,8 +13,8 @@ public record CreateFenceAssortsResult
public List<List<Item>>? SptItems { get; set; }
[JsonPropertyName("barter_scheme")]
public Dictionary<string, List<List<BarterScheme>>>? BarterScheme { get; set; }
public Dictionary<MongoId, List<List<BarterScheme>>>? BarterScheme { get; set; }
[JsonPropertyName("loyal_level_items")]
public Dictionary<string, int>? LoyalLevelItems { get; set; }
public Dictionary<MongoId, int>? LoyalLevelItems { get; set; }
}
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
namespace SPTarkov.Server.Core.Models.Spt.Mod;
@@ -15,7 +16,7 @@ public record NewItemFromCloneDetails : NewItemDetailsBase
/// Id of the item to copy and use as a base
/// </summary>
[JsonPropertyName("itemTplToClone")]
public string? ItemTplToClone { get; set; }
public MongoId? ItemTplToClone { get; set; }
/// <summary>
/// Item properties that should be applied over the top of the cloned base
@@ -85,7 +86,7 @@ public record CreateItemResult
public bool? Success { get; set; }
[JsonPropertyName("itemId")]
public string? ItemId { get; set; }
public MongoId? ItemId { get; set; }
[JsonPropertyName("errors")]
public List<string>? Errors { get; set; }
@@ -19,11 +19,11 @@ public class BotEquipmentModPoolService(
private readonly Lock _lockObject = new();
private ConcurrentDictionary<
string,
MongoId,
ConcurrentDictionary<string, HashSet<MongoId>>
>? _gearModPool;
protected ConcurrentDictionary<
string,
MongoId,
ConcurrentDictionary<string, HashSet<MongoId>>
> GearModPool
{
@@ -37,11 +37,11 @@ public class BotEquipmentModPoolService(
}
private ConcurrentDictionary<
string,
MongoId,
ConcurrentDictionary<string, HashSet<MongoId>>
>? _weaponModPool;
protected ConcurrentDictionary<
string,
MongoId,
ConcurrentDictionary<string, HashSet<MongoId>>
> WeaponModPool
{
@@ -60,7 +60,7 @@ public class BotEquipmentModPoolService(
/// <param name="inputItems"> Items to find related mods and store in modPool </param>
/// <param name="poolType"> Mod pool to choose from e.g. "weapon" for weaponModPool </param>
protected ConcurrentDictionary<
string,
MongoId,
ConcurrentDictionary<string, HashSet<MongoId>>
> GeneratePool(IEnumerable<TemplateItem>? inputItems, string poolType)
{
@@ -74,7 +74,7 @@ public class BotEquipmentModPoolService(
}
var pool =
new ConcurrentDictionary<string, ConcurrentDictionary<string, HashSet<MongoId>>>();
new ConcurrentDictionary<MongoId, ConcurrentDictionary<string, HashSet<MongoId>>>();
foreach (var item in inputItems)
{
if (item.Properties is null)
@@ -176,7 +176,7 @@ public class BotEquipmentModPoolService(
/// <param name="itemTpl"> Item to look up </param>
/// <param name="slotName"> Slot to get compatible mods for </param>
/// <returns> Hashset of tpls that fit the slot </returns>
public HashSet<MongoId> GetCompatibleModsForWeaponSlot(string itemTpl, string slotName)
public HashSet<MongoId> GetCompatibleModsForWeaponSlot(MongoId itemTpl, string slotName)
{
if (WeaponModPool.TryGetValue(itemTpl, out var value))
{
@@ -195,7 +195,7 @@ public class BotEquipmentModPoolService(
/// </summary>
/// <param name="itemTpl"> Items tpl to look up mods for </param>
/// <returns> Dictionary of mods (keys are mod slot names) with array of compatible mod tpls as value </returns>
public ConcurrentDictionary<string, HashSet<MongoId>> GetModsForGearSlot(string itemTpl)
public ConcurrentDictionary<string, HashSet<MongoId>> GetModsForGearSlot(MongoId itemTpl)
{
return GearModPool.TryGetValue(itemTpl, out var value) ? value : [];
}
@@ -205,7 +205,7 @@ public class BotEquipmentModPoolService(
/// </summary>
/// <param name="itemTpl"> Weapons tpl to look up mods for </param>
/// <returns> Dictionary of mods (keys are mod slot names) with array of compatible mod tpls as value </returns>
public ConcurrentDictionary<string, HashSet<MongoId>> GetModsForWeaponSlot(string itemTpl)
public ConcurrentDictionary<string, HashSet<MongoId>> GetModsForWeaponSlot(MongoId itemTpl)
{
return WeaponModPool.TryGetValue(itemTpl, out var value) ? value : [];
}
@@ -215,7 +215,7 @@ public class BotEquipmentModPoolService(
/// </summary>
/// <param name="itemTpl"> Weapons tpl to look up mods for </param>
/// <returns> Dictionary of mods (keys are mod slot names) with array of compatible mod tpls as value </returns>
public Dictionary<string, HashSet<MongoId>>? GetRequiredModsForWeaponSlot(string itemTpl)
public Dictionary<string, HashSet<MongoId>>? GetRequiredModsForWeaponSlot(MongoId itemTpl)
{
var result = new Dictionary<string, HashSet<MongoId>>();
@@ -248,7 +248,7 @@ public class BotEquipmentModPoolService(
/// Create weapon mod pool and set generated flag to true
/// </summary>
protected ConcurrentDictionary<
string,
MongoId,
ConcurrentDictionary<string, HashSet<MongoId>>
> GenerateWeaponPool()
{
@@ -266,7 +266,7 @@ public class BotEquipmentModPoolService(
/// Create gear mod pool and set generated flag to true
/// </summary>
protected ConcurrentDictionary<
string,
MongoId,
ConcurrentDictionary<string, HashSet<MongoId>>
> GenerateGearPool()
{
@@ -651,7 +651,7 @@ public class CircleOfCultistService(
/// <param name="itemTpl">Item chosen</param>
/// <param name="rewardPoolRemaining">Rouble amount of pool remaining to fill</param>
/// <returns>Size of stack</returns>
protected int GetRewardStackSize(string itemTpl, int rewardPoolRemaining)
protected int GetRewardStackSize(MongoId itemTpl, int rewardPoolRemaining)
{
if (_itemHelper.IsOfBaseclass(itemTpl, BaseClasses.AMMO))
{
@@ -167,8 +167,8 @@ public class FenceService(
var createAssort = new CreateFenceAssortsResult
{
SptItems = [],
BarterScheme = new Dictionary<string, List<List<BarterScheme>>>(),
LoyalLevelItems = new Dictionary<string, int>(),
BarterScheme = new Dictionary<MongoId, List<List<BarterScheme>>>(),
LoyalLevelItems = new Dictionary<MongoId, int>(),
};
createAssort.BarterScheme[root.Id] =
[
@@ -186,7 +186,7 @@ public class FenceService(
/// <param name="itemTpl"> The item tpl to calculate the fence price for </param>
/// <param name="items"> The items (with its children) to calculate fence price for </param>
/// <returns> Price of the item for Fence </returns>
public double? GetItemPrice(string itemTpl, List<Item> items)
public double? GetItemPrice(MongoId itemTpl, List<Item> items)
{
return itemHelper.IsOfBaseclass(itemTpl, BaseClasses.AMMO_BOX)
? GetAmmoBoxPrice(items) * traderConfig.Fence.ItemPriceMult
@@ -718,8 +718,8 @@ public class FenceService(
return new TraderAssort
{
Items = [],
BarterScheme = new Dictionary<string, List<List<BarterScheme>>>(),
LoyalLevelItems = new Dictionary<string, int>(),
BarterScheme = new Dictionary<MongoId, List<List<BarterScheme>>>(),
LoyalLevelItems = new Dictionary<MongoId, int>(),
NextResupply = GetNextFenceUpdateTimestamp(),
};
}
@@ -738,8 +738,8 @@ public class FenceService(
var result = new CreateFenceAssortsResult
{
SptItems = [],
BarterScheme = new Dictionary<string, List<List<BarterScheme>>>(),
LoyalLevelItems = new Dictionary<string, int>(),
BarterScheme = new Dictionary<MongoId, List<List<BarterScheme>>>(),
LoyalLevelItems = new Dictionary<MongoId, int>(),
};
var baseFenceAssortClone = _cloner.Clone(databaseService.GetTrader(Traders.FENCE).Assort);
@@ -1025,7 +1025,7 @@ public class FenceService(
/// <param name="itemRoot"> Root item having price adjusted </param>
/// <param name="itemTemplate"> DB template of item </param>
protected void AdjustItemPriceByQuality(
Dictionary<string, List<List<BarterScheme>>> barterSchemes,
Dictionary<MongoId, List<List<BarterScheme>>> barterSchemes,
Item itemRoot,
TemplateItem itemTemplate
)
@@ -48,7 +48,11 @@ public class CustomItemService(
}
// Clone existing item
var itemClone = cloner.Clone(tables.Templates.Items[newItemDetails.ItemTplToClone]);
tables.Templates.Items.TryGetValue(
newItemDetails.ItemTplToClone.Value,
out var itemToClone
);
var itemClone = cloner.Clone(itemToClone);
// Update id and parentId of item
itemClone.Id = newItemId;
@@ -590,7 +590,7 @@ public class PaymentService(
/// <param name="playerStashId"> Players stash ID </param>
/// <returns> True if it's in inventory </returns>
protected InventoryLocation GetItemLocation(
string itemId,
MongoId itemId,
List<Item> inventoryItems,
string playerStashId
)
@@ -15,9 +15,9 @@ public class RagfairLinkedItemService(
ISptLogger<RagfairLinkedItemService> logger
)
{
protected readonly Dictionary<string, HashSet<MongoId>> linkedItemsCache = new();
protected readonly Dictionary<MongoId, HashSet<MongoId>> linkedItemsCache = new();
public HashSet<MongoId> GetLinkedItems(string linkedSearchId)
public HashSet<MongoId> GetLinkedItems(MongoId linkedSearchId)
{
if (!linkedItemsCache.TryGetValue(linkedSearchId, out var set))
{
@@ -35,7 +35,7 @@ public class RagfairLinkedItemService(
/// </summary>
/// <param name="itemTpl"> Item to get sub-items for </param>
/// <returns> TemplateItem list </returns>
public List<TemplateItem> GetLinkedDbItems(string itemTpl)
public List<TemplateItem> GetLinkedDbItems(MongoId itemTpl)
{
var linkedItemsToWeaponTpls = GetLinkedItems(itemTpl);
return linkedItemsToWeaponTpls.Aggregate(
@@ -347,7 +347,7 @@ public class RagfairPriceService(
/// <returns>Adjusted price of item</returns>
protected double AdjustUnreasonablePrice(
UnreasonableModPrices unreasonableItemChange,
string itemTpl,
MongoId itemTpl,
double price
)
{
@@ -402,7 +402,7 @@ public class RagfairPriceService(
/// <param name="itemPrice">price of item</param>
/// <param name="itemTpl">item template Id being checked</param>
/// <returns>adjusted price value in roubles</returns>
protected double AdjustPriceIfBelowHandbook(double itemPrice, string itemTpl)
protected double AdjustPriceIfBelowHandbook(double itemPrice, MongoId itemTpl)
{
var itemHandbookPrice = GetStaticPriceForItem(itemTpl);
var priceDifferencePercent = GetPriceDifference(itemHandbookPrice.Value, itemPrice);
@@ -507,7 +507,7 @@ public class RagfairPriceService(
/// </summary>
/// <param name="itemTpl">Item to get highest price of</param>
/// <returns>rouble cost</returns>
protected double? GetHighestHandbookOrTraderPriceAsRouble(string itemTpl)
protected double? GetHighestHandbookOrTraderPriceAsRouble(MongoId itemTpl)
{
var price = GetStaticPriceForItem(itemTpl);
var traderPrice = _traderHelper.GetHighestSellToTraderPrice(itemTpl);
@@ -333,7 +333,7 @@ public class RepairService(
string sessionId,
PmcData pmcData,
List<RepairKitsInfo> repairKits,
string itemToRepairId,
MongoId itemToRepairId,
ItemEventRouterResponse output
)
{
@@ -28,7 +28,7 @@ public class SeasonalEventService(
{
private bool _christmasEventActive;
protected readonly HashSet<string> _christmasEventItems =
protected readonly HashSet<MongoId> _christmasEventItems =
[
ItemTpl.ARMOR_6B13_M_ASSAULT_ARMOR_CHRISTMAS_EDITION,
ItemTpl.BACKPACK_SANTAS_BAG,
@@ -71,7 +71,7 @@ public class SeasonalEventService(
private bool _halloweenEventActive;
protected readonly HashSet<string> _halloweenEventItems =
protected readonly HashSet<MongoId> _halloweenEventItems =
[
ItemTpl.HEADWEAR_JACKOLANTERN_TACTICAL_PUMPKIN_HELMET,
ItemTpl.FACECOVER_FACELESS_MASK,
@@ -103,7 +103,7 @@ public class SeasonalEventService(
/// Get an array of christmas items found in bots inventories as loot
/// </summary>
/// <returns>array</returns>
public HashSet<string> GetChristmasEventItems()
public HashSet<MongoId> GetChristmasEventItems()
{
return _christmasEventItems;
}
@@ -112,17 +112,17 @@ public class SeasonalEventService(
/// Get an array of halloween items found in bots inventories as loot
/// </summary>
/// <returns>array</returns>
public HashSet<string> GetHalloweenEventItems()
public HashSet<MongoId> GetHalloweenEventItems()
{
return _halloweenEventItems;
}
public bool ItemIsChristmasRelated(string itemTpl)
public bool ItemIsChristmasRelated(MongoId itemTpl)
{
return _christmasEventItems.Contains(itemTpl);
}
public bool ItemIsHalloweenRelated(string itemTpl)
public bool ItemIsHalloweenRelated(MongoId itemTpl)
{
return _halloweenEventItems.Contains(itemTpl);
}
@@ -132,7 +132,7 @@ public class SeasonalEventService(
/// </summary>
/// <param name="itemTpl">item tpl to check for</param>
/// <returns></returns>
public bool ItemIsSeasonalRelated(string itemTpl)
public bool ItemIsSeasonalRelated(MongoId itemTpl)
{
return _christmasEventItems.Contains(itemTpl) || _halloweenEventItems.Contains(itemTpl);
}
@@ -157,12 +157,12 @@ public class SeasonalEventService(
var items = new HashSet<MongoId>();
if (!ChristmasEventEnabled())
{
items.UnionWith(_christmasEventItems.ToMongoIds());
items.UnionWith(_christmasEventItems);
}
if (!HalloweenEventEnabled())
{
items.UnionWith(_halloweenEventItems.ToMongoIds());
items.UnionWith(_halloweenEventItems);
}
return items;