From f7906c91e3daed1c437b921f1229183fe949a208 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Thu, 1 May 2025 13:54:04 -0700 Subject: [PATCH] fix: ignore purchaseQuantity for webui add items (#1944) Closes #1942 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1944 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- src/controllers/custom/addItemsController.ts | 2 +- src/services/inventoryService.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/controllers/custom/addItemsController.ts b/src/controllers/custom/addItemsController.ts index 15837602..dc39ef64 100644 --- a/src/controllers/custom/addItemsController.ts +++ b/src/controllers/custom/addItemsController.ts @@ -7,7 +7,7 @@ export const addItemsController: RequestHandler = async (req, res) => { const requests = req.body as IAddItemRequest[]; const inventory = await getInventory(accountId); for (const request of requests) { - await addItem(inventory, request.ItemType, request.ItemCount, true); + await addItem(inventory, request.ItemType, request.ItemCount, true, undefined, undefined, true); } await inventory.save(); res.end(); diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 089e2fbb..a241e796 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -332,7 +332,8 @@ export const addItem = async ( quantity: number = 1, premiumPurchase: boolean = false, seed?: bigint, - targetFingerprint?: string + targetFingerprint?: string, + exactQuantity: boolean = false ): Promise => { // Bundles are technically StoreItems but a) they don't have a normal counterpart, and b) they are used in non-StoreItem contexts, e.g. email attachments. if (typeName in ExportBundles) { @@ -490,7 +491,9 @@ export const addItem = async ( // Multipling by purchase quantity for gear because: // - The Saya's Vigil scanner message has it as a non-counted attachment. // - Blueprints for Ancient Protector Specter, Shield Osprey Specter, etc. have num=1 despite giving their purchaseQuantity. - quantity *= ExportGear[typeName].purchaseQuantity ?? 1; + if (!exactQuantity) { + quantity *= ExportGear[typeName].purchaseQuantity ?? 1; + } const consumablesChanges = [ { ItemType: typeName,