chore: use mongoose's 'id' function in addGearExpByCategory
All checks were successful
Build / build (20) (push) Successful in 34s
Build / build (18) (push) Successful in 52s
Build / build (22) (push) Successful in 1m9s
Build / build (18) (pull_request) Successful in 36s
Build / build (20) (pull_request) Successful in 51s
Build / build (22) (pull_request) Successful in 1m12s

This commit is contained in:
Sainan 2025-02-03 21:19:17 +01:00
parent 241f0c894a
commit 63d1ae6b32

View File

@ -823,12 +823,10 @@ export const addGearExpByCategory = (
return; return;
} }
const itemIndex = ItemId ? category.findIndex(item => item._id?.equals(ItemId.$oid)) : -1; const item = category.id(ItemId.$oid);
if (itemIndex !== -1) { if (item) {
const item = category[itemIndex];
item.XP ??= 0; item.XP ??= 0;
item.XP += XP; item.XP += XP;
inventory.markModified(`${categoryName}.${itemIndex}.XP`);
const xpinfoIndex = inventory.XPInfo.findIndex(x => x.ItemType == item.ItemType); const xpinfoIndex = inventory.XPInfo.findIndex(x => x.ItemType == item.ItemType);
if (xpinfoIndex !== -1) { if (xpinfoIndex !== -1) {