chore: enforce that account only owns one of 'singleton items' (#969)
Reviewed-on: #969
This commit is contained in:
		
							parent
							
								
									7c2c0f9077
								
							
						
					
					
						commit
						9768e30ac6
					
				@ -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());
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user