feat: implement XPInfo #200

Merged
Sainan merged 2 commits from xpinfo into main 2024-05-08 13:53:06 -07:00
Showing only changes of commit 90ac508005 - Show all commits

View File

@ -201,12 +201,27 @@ const addGearExpByCategory = (
const category = inventory[categoryName]; const category = inventory[categoryName];
gearArray?.forEach(({ ItemId, XP }) => { gearArray?.forEach(({ ItemId, XP }) => {
const itemIndex = ItemId ? category.findIndex(item => item._id?.equals(ItemId.$oid)) : -1; if (!XP) {
const item = category[itemIndex]; return;
}
if (itemIndex !== -1 && item.XP != undefined) { const itemIndex = ItemId ? category.findIndex(item => item._id?.equals(ItemId.$oid)) : -1;
item.XP += XP || 0; if (itemIndex !== -1) {
const item = category[itemIndex];
item.XP ??= 0;
item.XP += XP;
inventory.markModified(`${categoryName}.${itemIndex}.XP`); inventory.markModified(`${categoryName}.${itemIndex}.XP`);
const xpinfoIndex = inventory.XPInfo.findIndex(x => x.ItemType == item.ItemType);
if (xpinfoIndex !== -1) {
const xpinfo = inventory.XPInfo[xpinfoIndex];
xpinfo.XP += XP;
} else {
inventory.XPInfo.push({
ItemType: item.ItemType,
XP: XP
});
}
} }
}); });
}; };