chore: add flavouritem to freestanding inventory
This commit is contained in:
parent
6e6c07eb02
commit
32318ca030
@ -170,11 +170,10 @@ export const addItem = async (
|
|||||||
return { InventoryChanges: inventoryChanges };
|
return { InventoryChanges: inventoryChanges };
|
||||||
}
|
}
|
||||||
if (typeName in ExportFlavour) {
|
if (typeName in ExportFlavour) {
|
||||||
return {
|
const inventory = await getInventory(accountId);
|
||||||
InventoryChanges: {
|
const inventoryChanges = addCustomization(inventory, typeName);
|
||||||
FlavourItems: [await addCustomization(typeName, accountId)]
|
await inventory.save();
|
||||||
}
|
return { InventoryChanges: inventoryChanges };
|
||||||
};
|
|
||||||
}
|
}
|
||||||
if (typeName in ExportUpgrades || typeName in ExportArcanes) {
|
if (typeName in ExportUpgrades || typeName in ExportArcanes) {
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
@ -574,11 +573,17 @@ export const addEquipment = async (
|
|||||||
return changedInventory[category][index - 1].toJSON() as object as IEquipmentClient;
|
return changedInventory[category][index - 1].toJSON() as object as IEquipmentClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addCustomization = async (customizatonName: string, accountId: string): Promise<IFlavourItem> => {
|
export const addCustomization = (
|
||||||
const inventory = await getInventory(accountId);
|
inventory: TInventoryDatabaseDocument,
|
||||||
const flavourItemIndex = inventory.FlavourItems.push({ ItemType: customizatonName }) - 1;
|
customizationName: string,
|
||||||
const changedInventory = await inventory.save();
|
inventoryChanges: IInventoryChanges = {}
|
||||||
return changedInventory.FlavourItems[flavourItemIndex].toJSON();
|
): IInventoryChanges => {
|
||||||
|
const flavourItemIndex = inventory.FlavourItems.push({ ItemType: customizationName }) - 1;
|
||||||
|
inventoryChanges.FlavourItems ??= [];
|
||||||
|
(inventoryChanges.FlavourItems as IFlavourItem[]).push(
|
||||||
|
inventory.FlavourItems[flavourItemIndex].toJSON<IFlavourItem>()
|
||||||
|
);
|
||||||
|
return inventoryChanges;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addSkin = (
|
export const addSkin = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user