fix: purchase response doesn't include exalted weapons when applicable
This commit is contained in:
parent
b5e0712675
commit
239dd45243
@ -219,16 +219,16 @@ export const addItem = async (
|
|||||||
case "Powersuits":
|
case "Powersuits":
|
||||||
switch (typeName.substr(1).split("/")[2]) {
|
switch (typeName.substr(1).split("/")[2]) {
|
||||||
default: {
|
default: {
|
||||||
const suit = await addPowerSuit(typeName, accountId);
|
const inventoryChanges = await addPowerSuit(typeName, accountId);
|
||||||
await updateSlots(accountId, InventorySlot.SUITS, 0, 1);
|
await updateSlots(accountId, InventorySlot.SUITS, 0, 1);
|
||||||
return {
|
return {
|
||||||
InventoryChanges: {
|
InventoryChanges: {
|
||||||
|
...inventoryChanges,
|
||||||
SuitBin: {
|
SuitBin: {
|
||||||
count: 1,
|
count: 1,
|
||||||
platinum: 0,
|
platinum: 0,
|
||||||
Slots: -1
|
Slots: -1
|
||||||
},
|
}
|
||||||
Suits: [suit]
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -247,16 +247,16 @@ export const addItem = async (
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
case "EntratiMech": {
|
case "EntratiMech": {
|
||||||
const mechSuit = await addMechSuit(typeName, accountId);
|
const inventoryChanges = await addMechSuit(typeName, accountId);
|
||||||
await updateSlots(accountId, InventorySlot.MECHSUITS, 0, 1);
|
await updateSlots(accountId, InventorySlot.MECHSUITS, 0, 1);
|
||||||
return {
|
return {
|
||||||
InventoryChanges: {
|
InventoryChanges: {
|
||||||
|
...inventoryChanges,
|
||||||
MechBin: {
|
MechBin: {
|
||||||
count: 1,
|
count: 1,
|
||||||
platinum: 0,
|
platinum: 0,
|
||||||
Slots: -1
|
Slots: -1
|
||||||
},
|
}
|
||||||
MechSuits: [mechSuit]
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -405,33 +405,41 @@ export const addSentinelWeapon = async (typeName: string, accountId: string) =>
|
|||||||
return changedInventory.SentinelWeapons[sentinelIndex - 1].toJSON();
|
return changedInventory.SentinelWeapons[sentinelIndex - 1].toJSON();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addPowerSuit = async (powersuitName: string, accountId: string): Promise<IEquipmentClient> => {
|
export const addPowerSuit = async (powersuitName: string, accountId: string): Promise<IInventoryChanges> => {
|
||||||
|
const inventoryChanges: IInventoryChanges = {};
|
||||||
const specialItems = getExalted(powersuitName);
|
const specialItems = getExalted(powersuitName);
|
||||||
if (specialItems) {
|
if (specialItems) {
|
||||||
for await (const specialItem of specialItems) {
|
for await (const specialItem of specialItems) {
|
||||||
await addSpecialItem(specialItem, accountId);
|
await addSpecialItem(specialItem, accountId, inventoryChanges);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 });
|
const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 });
|
||||||
const changedInventory = await inventory.save();
|
const changedInventory = await inventory.save();
|
||||||
return changedInventory.Suits[suitIndex - 1].toJSON() as object as IEquipmentClient;
|
inventoryChanges.Suits = [changedInventory.Suits[suitIndex - 1].toJSON()];
|
||||||
|
return inventoryChanges;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addMechSuit = async (mechsuitName: string, accountId: string) => {
|
export const addMechSuit = async (mechsuitName: string, accountId: string): Promise<IInventoryChanges> => {
|
||||||
|
const inventoryChanges: IInventoryChanges = {};
|
||||||
const specialItems = getExalted(mechsuitName);
|
const specialItems = getExalted(mechsuitName);
|
||||||
if (specialItems) {
|
if (specialItems) {
|
||||||
for await (const specialItem of specialItems) {
|
for await (const specialItem of specialItems) {
|
||||||
await addSpecialItem(specialItem, accountId);
|
await addSpecialItem(specialItem, accountId, inventoryChanges);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
const suitIndex = inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0 });
|
const suitIndex = inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0 });
|
||||||
const changedInventory = await inventory.save();
|
const changedInventory = await inventory.save();
|
||||||
return changedInventory.MechSuits[suitIndex - 1].toJSON();
|
inventoryChanges.MechSuits = [changedInventory.MechSuits[suitIndex - 1].toJSON()];
|
||||||
|
return inventoryChanges;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addSpecialItem = async (itemName: string, accountId: string): Promise<IEquipmentClient | undefined> => {
|
export const addSpecialItem = async (
|
||||||
|
itemName: string,
|
||||||
|
accountId: string,
|
||||||
|
inventoryChanges: IInventoryChanges
|
||||||
|
): Promise<void> => {
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
if (inventory.SpecialItems.find(x => x.ItemType == itemName)) {
|
if (inventory.SpecialItems.find(x => x.ItemType == itemName)) {
|
||||||
return;
|
return;
|
||||||
@ -444,7 +452,8 @@ export const addSpecialItem = async (itemName: string, accountId: string): Promi
|
|||||||
XP: 0
|
XP: 0
|
||||||
});
|
});
|
||||||
const changedInventory = await inventory.save();
|
const changedInventory = await inventory.save();
|
||||||
return changedInventory.SpecialItems[specialItemIndex - 1].toJSON<IEquipmentClient>();
|
inventoryChanges.SpecialItems ??= [];
|
||||||
|
(inventoryChanges.SpecialItems as object[]).push(changedInventory.SpecialItems[specialItemIndex - 1].toJSON());
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addSpaceSuit = async (spacesuitName: string, accountId: string) => {
|
export const addSpaceSuit = async (spacesuitName: string, accountId: string) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user