chore: handle addMiscItems & addMods resulting in account having 0 or less of a type #821

Merged
Sainan merged 2 commits from zero-to-remove into main 2025-01-19 03:29:19 -08:00
Showing only changes of commit 80a62244a1 - Show all commits

View File

@ -729,7 +729,13 @@ export const addMods = (inventory: TInventoryDatabaseDocument, itemsArray: IRawU
if (itemIndex !== -1) { if (itemIndex !== -1) {
RawUpgrades[itemIndex].ItemCount += ItemCount; RawUpgrades[itemIndex].ItemCount += ItemCount;
inventory.markModified(`RawUpgrades.${itemIndex}.ItemCount`); if (RawUpgrades[itemIndex].ItemCount <= 0) {
if (RawUpgrades[itemIndex].ItemCount == 0) {
RawUpgrades.splice(itemIndex, 1);
} else {
logger.warn(`account now owns a negative amount of ${ItemType}`);
}
}
} else { } else {
RawUpgrades.push({ ItemCount, ItemType }); RawUpgrades.push({ ItemCount, ItemType });
} }