From 1ba3378574d197de9c76b73e9d5accf7d23ce9d9 Mon Sep 17 00:00:00 2001 From: Sainan Date: Mon, 20 Jan 2025 18:29:25 +0100 Subject: [PATCH] fix(webui): properly handle unique level caps (#837) --- .../custom/getItemListsController.ts | 2 ++ static/webui/script.js | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/controllers/custom/getItemListsController.ts b/src/controllers/custom/getItemListsController.ts index fc71a228..14bdc021 100644 --- a/src/controllers/custom/getItemListsController.ts +++ b/src/controllers/custom/getItemListsController.ts @@ -4,6 +4,7 @@ import { ExportArcanes, ExportAvionics, ExportGear, + ExportMisc, ExportRecipes, ExportResources, ExportSentinels, @@ -163,6 +164,7 @@ const getItemListsController: RequestHandler = (req, response) => { response.json({ badItems, archonCrystalUpgrades, + uniqueLevelCaps: ExportMisc.uniqueLevelCaps, ...res }); }; diff --git a/static/webui/script.js b/static/webui/script.js index cc679c21..7f4d2b32 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -126,6 +126,7 @@ function setLanguage(lang) { updateInventory(); } +let uniqueLevelCaps = {}; function fetchItemList() { window.itemListPromise = new Promise(resolve => { const req = $.get("/custom/getItemLists?lang=" + window.lang); @@ -167,6 +168,8 @@ function fetchItemList() { option.value = name; document.getElementById("datalist-" + type).appendChild(option); }); + } else if (type == "uniqueLevelCaps") { + uniqueLevelCaps = items; } else if (type != "badItems") { items.forEach(item => { if (item.uniqueName in data.badItems) { @@ -235,14 +238,16 @@ function updateInventory() { { const td = document.createElement("td"); td.classList = "text-end text-nowrap"; - const maxXP = - category == "Suits" || - category == "SpaceSuits" || - category == "Sentinels" || - category == "Hoverboards" || - category == "MechSuits" - ? 1_600_000 - : 800_000; + let maxXP = Math.pow(uniqueLevelCaps[item.ItemType] ?? 30, 2) * 1000; + if ( + category != "Suits" && + category != "SpaceSuits" && + category != "Sentinels" && + category != "Hoverboards" && + category != "MechSuits" + ) { + maxXP /= 2; + } if ( item.XP < maxXP &&