chore: simplify upgradesController (#675)
This commit is contained in:
parent
e4613069b3
commit
a16158aedd
@ -13,7 +13,6 @@ export const upgradesController: RequestHandler = async (req, res) => {
|
|||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
const payload = JSON.parse(String(req.body)) as IUpgradesRequest;
|
const payload = JSON.parse(String(req.body)) as IUpgradesRequest;
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
const InventoryChanges: any = {};
|
|
||||||
for (const operation of payload.Operations) {
|
for (const operation of payload.Operations) {
|
||||||
if (
|
if (
|
||||||
operation.UpgradeRequirement == "/Lotus/Types/Items/MiscItems/ModSlotUnlocker" ||
|
operation.UpgradeRequirement == "/Lotus/Types/Items/MiscItems/ModSlotUnlocker" ||
|
||||||
@ -91,12 +90,6 @@ export const upgradesController: RequestHandler = async (req, res) => {
|
|||||||
if (item._id.toString() == payload.ItemId.$oid) {
|
if (item._id.toString() == payload.ItemId.$oid) {
|
||||||
item.ModSlotPurchases ??= 0;
|
item.ModSlotPurchases ??= 0;
|
||||||
item.ModSlotPurchases += 1;
|
item.ModSlotPurchases += 1;
|
||||||
InventoryChanges[payload.ItemCategory] = {
|
|
||||||
ItemId: {
|
|
||||||
$oid: payload.ItemId.$oid
|
|
||||||
},
|
|
||||||
ModSlotPurchases: item.ModSlotPurchases
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,12 +99,6 @@ export const upgradesController: RequestHandler = async (req, res) => {
|
|||||||
if (item._id.toString() == payload.ItemId.$oid) {
|
if (item._id.toString() == payload.ItemId.$oid) {
|
||||||
item.CustomizationSlotPurchases ??= 0;
|
item.CustomizationSlotPurchases ??= 0;
|
||||||
item.CustomizationSlotPurchases += 1;
|
item.CustomizationSlotPurchases += 1;
|
||||||
InventoryChanges[payload.ItemCategory] = {
|
|
||||||
ItemId: {
|
|
||||||
$oid: payload.ItemId.$oid
|
|
||||||
},
|
|
||||||
CustomizationSlotPurchases: item.CustomizationSlotPurchases
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,7 +121,7 @@ export const upgradesController: RequestHandler = async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
res.json({ InventoryChanges });
|
res.json({ InventoryChanges: {} });
|
||||||
};
|
};
|
||||||
|
|
||||||
const setSlotPolarity = (item: IEquipmentDatabase, slot: number, polarity: ArtifactPolarity): void => {
|
const setSlotPolarity = (item: IEquipmentDatabase, slot: number, polarity: ArtifactPolarity): void => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user