From dee302c996545fa2e534dba22880993ae84d7222 Mon Sep 17 00:00:00 2001 From: Sainan Date: Wed, 19 Feb 2025 13:53:21 -0800 Subject: [PATCH] chore: handle motorcycle in addItems (#970) Closes #968 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/970 --- src/services/inventoryService.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index de73a2ef..c2df25d0 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -516,6 +516,11 @@ export const addItem = async ( } }; } + case "Vehicles": + if (typeName == "/Lotus/Types/Vehicles/Motorcycle/MotorcyclePowerSuit") { + return { InventoryChanges: addMotorcycle(inventory, typeName) }; + } + break; } break; } @@ -853,6 +858,20 @@ const addCrewShipHarness = ( return inventoryChanges; }; +const addMotorcycle = ( + inventory: TInventoryDatabaseDocument, + typeName: string, + inventoryChanges: IInventoryChanges = {} +): IInventoryChanges => { + if (inventory.Motorcycles.length != 0) { + throw new Error("refusing to add Motorcycle because account already has one"); + } + const index = inventory.Motorcycles.push({ ItemType: typeName }) - 1; + inventoryChanges.Motorcycles ??= []; + (inventoryChanges.Motorcycles as object[]).push(inventory.Motorcycles[index].toJSON()); + return inventoryChanges; +}; + //TODO: wrong id is not erroring export const addGearExpByCategory = ( inventory: TInventoryDatabaseDocument,