From d1264b3549cf55036bb7804739b87c5d9b1ae18f Mon Sep 17 00:00:00 2001 From: Sainan Date: Wed, 19 Feb 2025 22:18:57 +0100 Subject: [PATCH] chore: enforce that account only owns one of 'singleton items' --- src/services/inventoryService.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 65ccd2d0..de73a2ef 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -830,6 +830,9 @@ const addCrewShip = ( typeName: string, inventoryChanges: IInventoryChanges = {} ): IInventoryChanges => { + if (inventory.CrewShips.length != 0) { + throw new Error("refusing to add CrewShip because account already has one"); + } const index = inventory.CrewShips.push({ ItemType: typeName }) - 1; inventoryChanges.CrewShips ??= []; (inventoryChanges.CrewShips as object[]).push(inventory.CrewShips[index].toJSON()); @@ -841,6 +844,9 @@ const addCrewShipHarness = ( typeName: string, inventoryChanges: IInventoryChanges = {} ): IInventoryChanges => { + if (inventory.CrewShips.length != 0) { + throw new Error("refusing to add CrewShipHarness because account already has one"); + } const index = inventory.CrewShipHarnesses.push({ ItemType: typeName }) - 1; inventoryChanges.CrewShipHarnesses ??= []; (inventoryChanges.CrewShipHarnesses as object[]).push(inventory.CrewShipHarnesses[index].toJSON()); -- 2.47.2