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