handle all weapon types in addWeapon
This commit is contained in:
		
							parent
							
								
									4ba718f27a
								
							
						
					
					
						commit
						9bf636418a
					
				@ -961,6 +961,7 @@ type InventoryDocumentProps = {
 | 
				
			|||||||
    SpaceSuits: Types.DocumentArray<IEquipmentDatabase>;
 | 
					    SpaceSuits: Types.DocumentArray<IEquipmentDatabase>;
 | 
				
			||||||
    SpaceGuns: Types.DocumentArray<IEquipmentDatabase>;
 | 
					    SpaceGuns: Types.DocumentArray<IEquipmentDatabase>;
 | 
				
			||||||
    SpaceMelee: Types.DocumentArray<IEquipmentDatabase>;
 | 
					    SpaceMelee: Types.DocumentArray<IEquipmentDatabase>;
 | 
				
			||||||
 | 
					    SentinelWeapons: Types.DocumentArray<IEquipmentDatabase>;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// eslint-disable-next-line @typescript-eslint/ban-types
 | 
					// eslint-disable-next-line @typescript-eslint/ban-types
 | 
				
			||||||
 | 
				
			|||||||
@ -416,24 +416,12 @@ export const addWeapon = async (
 | 
				
			|||||||
): Promise<IEquipmentClient> => {
 | 
					): Promise<IEquipmentClient> => {
 | 
				
			||||||
    const inventory = await getInventory(accountId);
 | 
					    const inventory = await getInventory(accountId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let weaponIndex;
 | 
					    const weaponIndex = inventory[weaponType].push({
 | 
				
			||||||
    switch (weaponType) {
 | 
					 | 
				
			||||||
        case "LongGuns":
 | 
					 | 
				
			||||||
        case "Pistols":
 | 
					 | 
				
			||||||
        case "Melee":
 | 
					 | 
				
			||||||
        case "OperatorAmps":
 | 
					 | 
				
			||||||
        case "SpaceGuns":
 | 
					 | 
				
			||||||
        case "SpaceMelee":
 | 
					 | 
				
			||||||
            weaponIndex = inventory[weaponType].push({
 | 
					 | 
				
			||||||
        ItemType: weaponName,
 | 
					        ItemType: weaponName,
 | 
				
			||||||
        Configs: [],
 | 
					        Configs: [],
 | 
				
			||||||
        XP: 0,
 | 
					        XP: 0,
 | 
				
			||||||
        ModularParts: modularParts
 | 
					        ModularParts: modularParts
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
        default:
 | 
					 | 
				
			||||||
            throw new Error("unknown weapon type: " + weaponType);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const changedInventory = await inventory.save();
 | 
					    const changedInventory = await inventory.save();
 | 
				
			||||||
    return changedInventory[weaponType][weaponIndex - 1].toJSON();
 | 
					    return changedInventory[weaponType][weaponIndex - 1].toJSON();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user