From 4a971841a1e17be925dcd9670f755af1865ba686 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Mon, 14 Apr 2025 07:13:51 -0700 Subject: [PATCH] fix: check addItems quantity for Drones & EmailItems (#1612) Closes #1610 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1612 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- src/services/inventoryService.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index d74bd9af..6357d404 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -381,7 +381,7 @@ export const addItem = async ( } else if (ExportResources[typeName].productCategory == "KubrowPetEggs") { const changes: IKubrowPetEggClient[] = []; if (quantity < 0 || quantity > 100) { - throw new Error(`unexpected acquisition quantity of KubrowPetEggs: ${quantity}`); + throw new Error(`unexpected acquisition quantity of KubrowPetEggs: got ${quantity}, expected 0..100`); } for (let i = 0; i != quantity; ++i) { const egg: IKubrowPetEggDatabase = { @@ -548,9 +548,18 @@ export const addItem = async ( } } if (typeName in ExportDrones) { - return addDrone(inventory, typeName); + // Can only get 1 at a time from crafting, but for convenience's sake, allow up 100 to via the WebUI. + if (quantity < 0 || quantity > 100) { + throw new Error(`unexpected acquisition quantity of Drones: got ${quantity}, expected 0..100`); + } + for (let i = 0; i != quantity; ++i) { + return addDrone(inventory, typeName); + } } if (typeName in ExportEmailItems) { + if (quantity != 1) { + throw new Error(`unexpected acquisition quantity of EmailItems: got ${quantity}, expected 1`); + } return await addEmailItem(inventory, typeName); }