chore: enforce that account only owns one of 'singleton items'
All checks were successful
Build / build (18) (push) Successful in 36s
Build / build (22) (pull_request) Successful in 33s
Build / build (20) (pull_request) Successful in 1m7s
Build / build (20) (push) Successful in 56s
Build / build (22) (push) Successful in 35s
Build / build (18) (pull_request) Successful in 56s

This commit is contained in:
Sainan 2025-02-19 22:18:57 +01:00
parent 00a75a33fa
commit d1264b3549

View File

@ -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());