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 740590dcba - Show all commits

View File

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