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)]
|
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":
|
case "Types":
|
||||||
switch (typeName.substr(1).split("/")[2]) {
|
switch (typeName.substr(1).split("/")[2]) {
|
||||||
case "AvatarImages":
|
case "AvatarImages":
|
||||||
@ -136,20 +153,40 @@ export const addItem = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
case "Items": {
|
case "Items": {
|
||||||
const inventory = await getInventory(accountId);
|
switch (typeName.substr(1).split("/")[3]) {
|
||||||
const miscItemChanges = [
|
case "ShipDecos": {
|
||||||
{
|
const inventory = await getInventory(accountId);
|
||||||
ItemType: typeName,
|
const changes = [
|
||||||
ItemCount: quantity
|
{
|
||||||
} satisfies IMiscItem
|
ItemType: typeName,
|
||||||
];
|
ItemCount: quantity
|
||||||
addMiscItems(inventory, miscItemChanges);
|
} satisfies IMiscItem
|
||||||
await inventory.save();
|
];
|
||||||
return {
|
addShipDecorations(inventory, changes);
|
||||||
InventoryChanges: {
|
await inventory.save();
|
||||||
MiscItems: miscItemChanges
|
return {
|
||||||
|
InventoryChanges: {
|
||||||
|
ShipDecorations: changes
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
default: {
|
||||||
|
const inventory = await getInventory(accountId);
|
||||||
|
const miscItemChanges = [
|
||||||
|
{
|
||||||
|
ItemType: typeName,
|
||||||
|
ItemCount: quantity
|
||||||
|
} satisfies IMiscItem
|
||||||
|
];
|
||||||
|
addMiscItems(inventory, miscItemChanges);
|
||||||
|
await inventory.save();
|
||||||
|
return {
|
||||||
|
InventoryChanges: {
|
||||||
|
MiscItems: miscItemChanges
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "Recipes":
|
case "Recipes":
|
||||||
case "Consumables": {
|
case "Consumables": {
|
||||||
@ -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) => {
|
export const addConsumables = (inventory: IInventoryDatabaseDocument, itemsArray: IConsumable[] | undefined) => {
|
||||||
const { Consumables } = inventory;
|
const { Consumables } = inventory;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user