From 4af5b2c343eb09f5b43ddfa9028bf027b7f5b58f Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:02:49 +0100 Subject: [PATCH 1/2] chore: fix wording of error when an item goes negative It would say "subtracting -1" instead of "adding -1" or "subtracting 1" --- src/services/inventoryService.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 761b3d5b..d6fba392 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1850,7 +1850,9 @@ export const addMiscItems = (inventory: TInventoryDatabaseDocument, itemsArray: if (MiscItems[itemIndex].ItemCount == 0) { MiscItems.splice(itemIndex, 1); } else if (MiscItems[itemIndex].ItemCount < 0) { - throw new Error(`inventory.MiscItems has a negative count for ${ItemType} after subtracting ${ItemCount}`); + throw new Error( + `inventory.MiscItems has a negative count for ${ItemType} after subtracting ${ItemCount * -1}` + ); } }); }; @@ -1873,7 +1875,7 @@ const applyArrayChanges = ( arr.splice(itemIndex, 1); } else if (arr[itemIndex].ItemCount < 0) { throw new Error( - `inventory.${key} has a negative count for ${change.ItemType} after subtracting ${change.ItemCount}` + `inventory.${key} has a negative count for ${change.ItemType} after subtracting ${change.ItemCount * -1}` ); } } @@ -1922,7 +1924,7 @@ export const addMods = (inventory: TInventoryDatabaseDocument, itemsArray: IRawU RawUpgrades.splice(itemIndex, 1); } else if (RawUpgrades[itemIndex].ItemCount < 0) { throw new Error( - `inventory.RawUpgrades has a negative count for ${ItemType} after subtracting ${ItemCount}` + `inventory.RawUpgrades has a negative count for ${ItemType} after subtracting ${ItemCount * -1}` ); } }); @@ -1939,7 +1941,7 @@ export const addFusionTreasures = (inventory: TInventoryDatabaseDocument, itemsA FusionTreasures.splice(itemIndex, 1); } else if (FusionTreasures[itemIndex].ItemCount <= 0) { throw new Error( - `inventory.FusionTreasures has a negative count for ${ItemType} after subtracting ${ItemCount}` + `inventory.FusionTreasures has a negative count for ${ItemType} after subtracting ${ItemCount * -1}` ); } } else { -- 2.49.1 From a2e7e6e64032446a7bb1199c12681ac757f0fa00 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:09:10 +0100 Subject: [PATCH 2/2] also note count after subtraction --- src/services/inventoryService.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index d6fba392..bdd8bc4a 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1851,7 +1851,7 @@ export const addMiscItems = (inventory: TInventoryDatabaseDocument, itemsArray: MiscItems.splice(itemIndex, 1); } else if (MiscItems[itemIndex].ItemCount < 0) { throw new Error( - `inventory.MiscItems has a negative count for ${ItemType} after subtracting ${ItemCount * -1}` + `Cannot remove ${ItemCount * -1}x ${ItemType} from MiscItems, would be left with ${MiscItems[itemIndex].ItemCount}` ); } }); @@ -1875,7 +1875,7 @@ const applyArrayChanges = ( arr.splice(itemIndex, 1); } else if (arr[itemIndex].ItemCount < 0) { throw new Error( - `inventory.${key} has a negative count for ${change.ItemType} after subtracting ${change.ItemCount * -1}` + `Cannot remove ${change.ItemCount * -1}x ${change.ItemType} from ${key}, would be left with ${arr[itemIndex].ItemCount}` ); } } @@ -1924,7 +1924,7 @@ export const addMods = (inventory: TInventoryDatabaseDocument, itemsArray: IRawU RawUpgrades.splice(itemIndex, 1); } else if (RawUpgrades[itemIndex].ItemCount < 0) { throw new Error( - `inventory.RawUpgrades has a negative count for ${ItemType} after subtracting ${ItemCount * -1}` + `Cannot remove ${ItemCount * -1}x ${ItemType} from RawUpgrades, would be left with ${RawUpgrades[itemIndex].ItemCount}` ); } }); @@ -1941,7 +1941,7 @@ export const addFusionTreasures = (inventory: TInventoryDatabaseDocument, itemsA FusionTreasures.splice(itemIndex, 1); } else if (FusionTreasures[itemIndex].ItemCount <= 0) { throw new Error( - `inventory.FusionTreasures has a negative count for ${ItemType} after subtracting ${ItemCount * -1}` + `Cannot remove ${ItemCount * -1}x ${ItemType} from FusionTreasures, would be left with ${FusionTreasures[itemIndex].ItemCount}` ); } } else { -- 2.49.1