From dc85be8f3788ba1d6acd3fbc24ea49b1210949e5 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sun, 29 Dec 2024 03:42:22 +0100 Subject: [PATCH 1/4] fix: purchase response doesn't include exalted weapons when applicable (#647) --- src/services/inventoryService.ts | 37 ++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 78f4f219..423be170 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -219,16 +219,16 @@ export const addItem = async ( case "Powersuits": switch (typeName.substr(1).split("/")[2]) { default: { - const suit = await addPowerSuit(typeName, accountId); + const inventoryChanges = await addPowerSuit(typeName, accountId); await updateSlots(accountId, InventorySlot.SUITS, 0, 1); return { InventoryChanges: { + ...inventoryChanges, SuitBin: { count: 1, platinum: 0, Slots: -1 - }, - Suits: [suit] + } } }; } @@ -247,16 +247,16 @@ export const addItem = async ( }; } case "EntratiMech": { - const mechSuit = await addMechSuit(typeName, accountId); + const inventoryChanges = await addMechSuit(typeName, accountId); await updateSlots(accountId, InventorySlot.MECHSUITS, 0, 1); return { InventoryChanges: { + ...inventoryChanges, MechBin: { count: 1, platinum: 0, Slots: -1 - }, - MechSuits: [mechSuit] + } } }; } @@ -405,33 +405,41 @@ export const addSentinelWeapon = async (typeName: string, accountId: string) => return changedInventory.SentinelWeapons[sentinelIndex - 1].toJSON(); }; -export const addPowerSuit = async (powersuitName: string, accountId: string): Promise => { +export const addPowerSuit = async (powersuitName: string, accountId: string): Promise => { + const inventoryChanges: IInventoryChanges = {}; const specialItems = getExalted(powersuitName); if (specialItems) { for await (const specialItem of specialItems) { - await addSpecialItem(specialItem, accountId); + await addSpecialItem(specialItem, accountId, inventoryChanges); } } const inventory = await getInventory(accountId); const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 }); 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 => { + const inventoryChanges: IInventoryChanges = {}; const specialItems = getExalted(mechsuitName); if (specialItems) { for await (const specialItem of specialItems) { - await addSpecialItem(specialItem, accountId); + await addSpecialItem(specialItem, accountId, inventoryChanges); } } const inventory = await getInventory(accountId); const suitIndex = inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0 }); 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 => { +export const addSpecialItem = async ( + itemName: string, + accountId: string, + inventoryChanges: IInventoryChanges +): Promise => { const inventory = await getInventory(accountId); if (inventory.SpecialItems.find(x => x.ItemType == itemName)) { return; @@ -444,7 +452,8 @@ export const addSpecialItem = async (itemName: string, accountId: string): Promi XP: 0 }); const changedInventory = await inventory.save(); - return changedInventory.SpecialItems[specialItemIndex - 1].toJSON(); + inventoryChanges.SpecialItems ??= []; + (inventoryChanges.SpecialItems as object[]).push(changedInventory.SpecialItems[specialItemIndex - 1].toJSON()); }; export const addSpaceSuit = async (spacesuitName: string, accountId: string) => { -- 2.47.2 From 4c5193f084f9f689de55fe6bcf26c55e14679f18 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sun, 29 Dec 2024 03:33:03 +0100 Subject: [PATCH 2/4] improve: for "make rank 30", also make respective exalted items rank 30 --- src/controllers/custom/getItemListsController.ts | 3 ++- static/webui/script.js | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/controllers/custom/getItemListsController.ts b/src/controllers/custom/getItemListsController.ts index e3fa95a1..24b8c0ae 100644 --- a/src/controllers/custom/getItemListsController.ts +++ b/src/controllers/custom/getItemListsController.ts @@ -89,7 +89,8 @@ const getItemListsController: RequestHandler = (req, res) => { .map(([uniqueName, warframe]) => { return { uniqueName, - name: getString(warframe.name, lang) + name: getString(warframe.name, lang), + exalted: warframe.exalted }; }), weapons, diff --git a/static/webui/script.js b/static/webui/script.js index 56736c38..58466a06 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -203,6 +203,17 @@ function updateInventory() { a.onclick = function (event) { event.preventDefault(); addGearExp("Suits", item.ItemId.$oid, 1_600_000 - item.XP); + if ("exalted" in itemMap[item.ItemType]) { + for (const exaltedType of itemMap[item.ItemType].exalted) { + const exaltedItem = data.SpecialItems.find(x => x.ItemType == exaltedType); + if (exaltedItem) { + const exaltedCap = itemMap[exaltedType]?.type == "weapons" ? 800_000 : 1_600_000; + if (exaltedItem.XP < exaltedCap) { + addGearExp("SpecialItems", exaltedItem.ItemId.$oid, exaltedCap - exaltedItem.XP); + } + } + } + } }; a.title = "Make Rank 30"; a.innerHTML = ``; @@ -562,7 +573,9 @@ function addGearExp(category, oid, xp) { contentType: "text/plain", data: JSON.stringify(data) }).done(function () { - updateInventory(); + if (category != "SpecialItems") { + updateInventory(); + } }); }); } -- 2.47.2 From bbe9656880befb450fd466be2ec15642c3e29254 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sun, 29 Dec 2024 04:16:25 +0100 Subject: [PATCH 3/4] "prettier" --- static/webui/script.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/static/webui/script.js b/static/webui/script.js index 58466a06..e5a6e03e 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -207,9 +207,14 @@ function updateInventory() { for (const exaltedType of itemMap[item.ItemType].exalted) { const exaltedItem = data.SpecialItems.find(x => x.ItemType == exaltedType); if (exaltedItem) { - const exaltedCap = itemMap[exaltedType]?.type == "weapons" ? 800_000 : 1_600_000; + const exaltedCap = + itemMap[exaltedType]?.type == "weapons" ? 800_000 : 1_600_000; if (exaltedItem.XP < exaltedCap) { - addGearExp("SpecialItems", exaltedItem.ItemId.$oid, exaltedCap - exaltedItem.XP); + addGearExp( + "SpecialItems", + exaltedItem.ItemId.$oid, + exaltedCap - exaltedItem.XP + ); } } } -- 2.47.2 From b0c3e725f86b93eaeb05b64ab081c309ffa8276c Mon Sep 17 00:00:00 2001 From: Sainan Date: Sun, 29 Dec 2024 05:37:48 +0100 Subject: [PATCH 4/4] chore: fix no-case-declarations warnings --- src/controllers/custom/addItemController.ts | 6 ++++-- src/services/inventoryService.ts | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/controllers/custom/addItemController.ts b/src/controllers/custom/addItemController.ts index ea5fd535..c1045e63 100644 --- a/src/controllers/custom/addItemController.ts +++ b/src/controllers/custom/addItemController.ts @@ -9,15 +9,17 @@ const addItemController: RequestHandler = async (req, res) => { const request = toAddItemRequest(req.body); switch (request.type) { - case ItemType.Powersuit: + case ItemType.Powersuit: { const powersuit = await addPowerSuit(request.InternalName, accountId); res.json(powersuit); return; - case ItemType.Weapon: + } + case ItemType.Weapon: { const weaponType = getWeaponType(request.InternalName); const weapon = await addEquipment(weaponType, request.InternalName, accountId); res.json(weapon); break; + } default: res.status(400).json({ error: "something went wrong" }); break; diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 423be170..9d51f597 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -262,7 +262,7 @@ export const addItem = async ( } } break; - case "Weapons": + case "Weapons": { const weaponType = getWeaponType(typeName); const weapon = await addEquipment(weaponType, typeName, accountId); await updateSlots(accountId, InventorySlot.WEAPONS, 0, 1); @@ -272,6 +272,7 @@ export const addItem = async ( [weaponType]: [weapon] } }; + } case "Objects": { // /Lotus/Objects/Tenno/Props/TnoLisetTextProjector (Note Beacon) const inventory = await getInventory(accountId); -- 2.47.2