From a545d4f04736e635aa6c2194116d6c49bf3602f9 Mon Sep 17 00:00:00 2001 From: neon Date: Wed, 15 Jan 2025 10:29:02 -0500 Subject: [PATCH] feat(webui): add "max rank all warframes" & "max rank all weapons" (#783) Co-authored-by: Sainan --- static/webui/index.html | 24 +++++++------ static/webui/script.js | 80 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 11 deletions(-) diff --git a/static/webui/index.html b/static/webui/index.html index 81cbdb1e..114464ba 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -96,9 +96,9 @@
-
+
Warframes
-
+
@@ -108,18 +108,11 @@
-
-
Bulk Actions
-
- - -
-
-
+
Weapons
-
+
@@ -131,6 +124,15 @@
+
+
Bulk Actions
+
+ + + + +
+

diff --git a/static/webui/script.js b/static/webui/script.js index 84b1a8c7..a6b87312 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -605,6 +605,46 @@ function addMissingWarframes() { } } +function maxRankAllWarframes() { + const req = $.get("/api/inventory.php?" + window.authz + "&xpBasedLevelCapDisabled=1"); + + req.done(data => { + window.itemListPromise.then(itemMap => { + const batchData = { Suits: [], SpecialItems: [] }; + + data.Suits.forEach(item => { + if (item.XP < 1_600_000) { + batchData.Suits.push({ + ItemId: { $oid: item.ItemId.$oid }, + XP: 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) { + batchData.SpecialItems.push({ + ItemId: { $oid: exaltedItem.ItemId.$oid }, + XP: exaltedCap + }); + } + } + } + } + }); + + if (batchData.Suits.length > 0 || batchData.SpecialItems.length > 0) { + return sendBatchGearExp(batchData); + } + + alert("No Warframes to rank up."); + }); + }); +} + function addMissingWeapons() { const requests = []; document.querySelectorAll("#datalist-weapons option").forEach(elm => { @@ -620,6 +660,34 @@ function addMissingWeapons() { } } +function maxRankAllWeapons() { + const req = $.get("/api/inventory.php?" + window.authz + "&xpBasedLevelCapDisabled=1"); + + req.done(data => { + const batchData = {}; + + ["LongGuns", "Pistols", "Melee"].forEach(category => { + data[category].forEach(item => { + if (item.XP < 800_000) { + if (!batchData[category]) { + batchData[category] = []; + } + batchData[category].push({ + ItemId: { $oid: item.ItemId.$oid }, + XP: 800_000 - item.XP + }); + } + }); + }); + + if (Object.keys(batchData).length > 0) { + return sendBatchGearExp(batchData); + } + + alert("No weapons to rank up."); + }); +} + function addGearExp(category, oid, xp) { const data = {}; data[category] = [ @@ -641,6 +709,18 @@ function addGearExp(category, oid, xp) { }); } +function sendBatchGearExp(data) { + revalidateAuthz(() => { + $.post({ + url: "/api/missionInventoryUpdate.php?" + window.authz, + contentType: "text/plain", + data: JSON.stringify(data) + }).done(() => { + updateInventory(); + }); + }); +} + function renameGear(category, oid, name) { revalidateAuthz(() => { $.post({