fix: refuse to add items non-fatally #1476
@ -1071,11 +1071,12 @@ const addCrewShip = (
 | 
			
		||||
    inventoryChanges: IInventoryChanges = {}
 | 
			
		||||
): IInventoryChanges => {
 | 
			
		||||
    if (inventory.CrewShips.length != 0) {
 | 
			
		||||
        throw new Error("refusing to add CrewShip because account already has one");
 | 
			
		||||
        logger.error("refusing to add CrewShip because account already has one");
 | 
			
		||||
    } else {
 | 
			
		||||
        const index = inventory.CrewShips.push({ ItemType: typeName }) - 1;
 | 
			
		||||
        inventoryChanges.CrewShips ??= [];
 | 
			
		||||
        inventoryChanges.CrewShips.push(inventory.CrewShips[index].toJSON<IEquipmentClient>());
 | 
			
		||||
    }
 | 
			
		||||
    const index = inventory.CrewShips.push({ ItemType: typeName }) - 1;
 | 
			
		||||
    inventoryChanges.CrewShips ??= [];
 | 
			
		||||
    inventoryChanges.CrewShips.push(inventory.CrewShips[index].toJSON<IEquipmentClient>());
 | 
			
		||||
    return inventoryChanges;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -1085,11 +1086,12 @@ const addCrewShipHarness = (
 | 
			
		||||
    inventoryChanges: IInventoryChanges = {}
 | 
			
		||||
): IInventoryChanges => {
 | 
			
		||||
    if (inventory.CrewShipHarnesses.length != 0) {
 | 
			
		||||
        throw new Error("refusing to add CrewShipHarness because account already has one");
 | 
			
		||||
        logger.error("refusing to add CrewShipHarness because account already has one");
 | 
			
		||||
    } else {
 | 
			
		||||
        const index = inventory.CrewShipHarnesses.push({ ItemType: typeName }) - 1;
 | 
			
		||||
        inventoryChanges.CrewShipHarnesses ??= [];
 | 
			
		||||
        inventoryChanges.CrewShipHarnesses.push(inventory.CrewShipHarnesses[index].toJSON<IEquipmentClient>());
 | 
			
		||||
    }
 | 
			
		||||
    const index = inventory.CrewShipHarnesses.push({ ItemType: typeName }) - 1;
 | 
			
		||||
    inventoryChanges.CrewShipHarnesses ??= [];
 | 
			
		||||
    inventoryChanges.CrewShipHarnesses.push(inventory.CrewShipHarnesses[index].toJSON<IEquipmentClient>());
 | 
			
		||||
    return inventoryChanges;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -1099,11 +1101,12 @@ const addMotorcycle = (
 | 
			
		||||
    inventoryChanges: IInventoryChanges = {}
 | 
			
		||||
): IInventoryChanges => {
 | 
			
		||||
    if (inventory.Motorcycles.length != 0) {
 | 
			
		||||
        throw new Error("refusing to add Motorcycle because account already has one");
 | 
			
		||||
        logger.error("refusing to add Motorcycle because account already has one");
 | 
			
		||||
    } else {
 | 
			
		||||
        const index = inventory.Motorcycles.push({ ItemType: typeName }) - 1;
 | 
			
		||||
        inventoryChanges.Motorcycles ??= [];
 | 
			
		||||
        inventoryChanges.Motorcycles.push(inventory.Motorcycles[index].toJSON<IEquipmentClient>());
 | 
			
		||||
    }
 | 
			
		||||
    const index = inventory.Motorcycles.push({ ItemType: typeName }) - 1;
 | 
			
		||||
    inventoryChanges.Motorcycles ??= [];
 | 
			
		||||
    inventoryChanges.Motorcycles.push(inventory.Motorcycles[index].toJSON<IEquipmentClient>());
 | 
			
		||||
    return inventoryChanges;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user