From d918b0c982054a583d1538641609477e93659bc4 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Thu, 3 Apr 2025 10:38:11 -0700 Subject: [PATCH] fix: don't remove consumed argon crystals from FoundToday (#1447) This fixes a possible mongo conflict when ticking them, and this is probably more desirable as you wanna consume unstable crystals first. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1447 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- src/controllers/api/inventoryController.ts | 6 ++++-- src/services/inventoryService.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/controllers/api/inventoryController.ts b/src/controllers/api/inventoryController.ts index e2f4a99d..cef69be7 100644 --- a/src/controllers/api/inventoryController.ts +++ b/src/controllers/api/inventoryController.ts @@ -51,9 +51,11 @@ export const inventoryController: RequestHandler = async (request, response) => if (numArgonCrystals == 0) { break; } - const numStableArgonCrystals = + const numStableArgonCrystals = Math.min( + numArgonCrystals, inventory.FoundToday?.find(x => x.ItemType == "/Lotus/Types/Items/MiscItems/ArgonCrystal") - ?.ItemCount ?? 0; + ?.ItemCount ?? 0 + ); const numDecayingArgonCrystals = numArgonCrystals - numStableArgonCrystals; const numDecayingArgonCrystalsToRemove = Math.ceil(numDecayingArgonCrystals / 2); logger.debug(`ticking argon crystals for day ${i + 1} of ${daysPassed}`, { diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 9f9e7327..b15bde8c 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1119,7 +1119,7 @@ export const addMiscItems = (inventory: TInventoryDatabaseDocument, itemsArray: MiscItems[itemIndex].ItemCount += ItemCount; - if (ItemType == "/Lotus/Types/Items/MiscItems/ArgonCrystal") { + if (ItemType == "/Lotus/Types/Items/MiscItems/ArgonCrystal" && ItemCount > 0) { inventory.FoundToday ??= []; let foundTodayIndex = inventory.FoundToday.findIndex(x => x.ItemType == ItemType); if (foundTodayIndex == -1) {