feat: ability to purchase ship decorations
Previously, you could already "purchase" most of them, but because they were added to MiscItems instead of ShipDecorations, they weren't actually usable.
This commit is contained in:
parent
e5451d5227
commit
eac5330e6f
@ -116,6 +116,23 @@ export const addItem = async (
|
||||
FlavourItems: [await addCustomization(typeName, accountId)]
|
||||
}
|
||||
};
|
||||
case "Objects": {
|
||||
// /Lotus/Objects/Tenno/Props/TnoLisetTextProjector (Note Beacon)
|
||||
const inventory = await getInventory(accountId);
|
||||
const changes = [
|
||||
{
|
||||
ItemType: typeName,
|
||||
ItemCount: quantity
|
||||
} satisfies IMiscItem
|
||||
];
|
||||
addShipDecorations(inventory, changes);
|
||||
await inventory.save();
|
||||
return {
|
||||
InventoryChanges: {
|
||||
ShipDecorations: changes
|
||||
}
|
||||
};
|
||||
}
|
||||
case "Types":
|
||||
switch (typeName.substr(1).split("/")[2]) {
|
||||
case "AvatarImages":
|
||||
@ -136,6 +153,24 @@ export const addItem = async (
|
||||
}
|
||||
};
|
||||
case "Items": {
|
||||
switch (typeName.substr(1).split("/")[3]) {
|
||||
case "ShipDecos": {
|
||||
const inventory = await getInventory(accountId);
|
||||
const changes = [
|
||||
{
|
||||
ItemType: typeName,
|
||||
ItemCount: quantity
|
||||
} satisfies IMiscItem
|
||||
];
|
||||
addShipDecorations(inventory, changes);
|
||||
await inventory.save();
|
||||
return {
|
||||
InventoryChanges: {
|
||||
ShipDecorations: changes
|
||||
}
|
||||
};
|
||||
}
|
||||
default: {
|
||||
const inventory = await getInventory(accountId);
|
||||
const miscItemChanges = [
|
||||
{
|
||||
@ -151,6 +186,8 @@ export const addItem = async (
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
case "Recipes":
|
||||
case "Consumables": {
|
||||
// Blueprints for Ciphers, Antitoxins
|
||||
@ -427,6 +464,21 @@ export const addMiscItems = (inventory: IInventoryDatabaseDocument, itemsArray:
|
||||
});
|
||||
};
|
||||
|
||||
export const addShipDecorations = (inventory: IInventoryDatabaseDocument, itemsArray: IConsumable[] | undefined) => {
|
||||
const { ShipDecorations } = inventory;
|
||||
|
||||
itemsArray?.forEach(({ ItemCount, ItemType }) => {
|
||||
const itemIndex = ShipDecorations.findIndex(miscItem => miscItem.ItemType === ItemType);
|
||||
|
||||
if (itemIndex !== -1) {
|
||||
ShipDecorations[itemIndex].ItemCount += ItemCount;
|
||||
inventory.markModified(`ShipDecorations.${itemIndex}.ItemCount`);
|
||||
} else {
|
||||
ShipDecorations.push({ ItemCount, ItemType });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const addConsumables = (inventory: IInventoryDatabaseDocument, itemsArray: IConsumable[] | undefined) => {
|
||||
const { Consumables } = inventory;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user