chore: add spacesuit to freestanding inventory
This commit is contained in:
parent
32318ca030
commit
9544786e5c
@ -229,16 +229,18 @@ export const addItem = async (
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
case "Archwing": {
|
case "Archwing": {
|
||||||
const spaceSuit = await addSpaceSuit(typeName, accountId);
|
const inventory = await getInventory(accountId);
|
||||||
|
const inventoryChanges = addSpaceSuit(inventory, typeName);
|
||||||
|
await inventory.save();
|
||||||
await updateSlots(accountId, InventorySlot.SPACESUITS, 0, 1);
|
await updateSlots(accountId, InventorySlot.SPACESUITS, 0, 1);
|
||||||
return {
|
return {
|
||||||
InventoryChanges: {
|
InventoryChanges: {
|
||||||
|
...inventoryChanges,
|
||||||
SpaceSuitBin: {
|
SpaceSuitBin: {
|
||||||
count: 1,
|
count: 1,
|
||||||
platinum: 0,
|
platinum: 0,
|
||||||
Slots: -1
|
Slots: -1
|
||||||
},
|
}
|
||||||
SpaceSuits: [spaceSuit]
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -460,11 +462,17 @@ export const addSpecialItem = (
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addSpaceSuit = async (spacesuitName: string, accountId: string): Promise<IEquipmentClient> => {
|
export const addSpaceSuit = (
|
||||||
const inventory = await getInventory(accountId);
|
inventory: TInventoryDatabaseDocument,
|
||||||
const suitIndex = inventory.SpaceSuits.push({ ItemType: spacesuitName, Configs: [], UpgradeVer: 101, XP: 0 });
|
spacesuitName: string,
|
||||||
const changedInventory = await inventory.save();
|
inventoryChanges: IInventoryChanges = {}
|
||||||
return changedInventory.SpaceSuits[suitIndex - 1].toJSON<IEquipmentClient>();
|
): IInventoryChanges => {
|
||||||
|
const suitIndex = inventory.SpaceSuits.push({ ItemType: spacesuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
|
||||||
|
inventoryChanges.SpaceSuits ??= [];
|
||||||
|
(inventoryChanges.SpaceSuits as IEquipmentClient[]).push(
|
||||||
|
inventory.SpaceSuits[suitIndex - 1].toJSON<IEquipmentClient>()
|
||||||
|
);
|
||||||
|
return inventoryChanges;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateSlots = async (
|
export const updateSlots = async (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user