From 9267c9929e9fde3df0953e9beaacb004af16acfa Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 27 Feb 2025 18:00:37 -0800 Subject: [PATCH] feat(webui): acquire flawed mods & imposters via add mods (#1040) Closes #1033 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1040 --- .../custom/getItemListsController.ts | 23 +++++++++++-------- static/webui/script.js | 13 +++++++---- static/webui/translations/en.js | 1 + static/webui/translations/ru.js | 1 + 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/controllers/custom/getItemListsController.ts b/src/controllers/custom/getItemListsController.ts index 86488d121..ce80d041e 100644 --- a/src/controllers/custom/getItemListsController.ts +++ b/src/controllers/custom/getItemListsController.ts @@ -20,6 +20,7 @@ interface ListedItem { name: string; fusionLimit?: number; exalted?: string[]; + badReason?: "starter" | "frivolous" | "notraw"; } const getItemListsController: RequestHandler = (req, response) => { @@ -132,16 +133,20 @@ const getItemListsController: RequestHandler = (req, response) => { } res.mods = []; - const badItems: Record = {}; for (const [uniqueName, upgrade] of Object.entries(ExportUpgrades)) { - res.mods.push({ + const mod: ListedItem = { uniqueName, name: getString(upgrade.name, lang), fusionLimit: upgrade.fusionLimit - }); - if (upgrade.isStarter || upgrade.isFrivolous || upgrade.upgradeEntries) { - badItems[uniqueName] = true; + }; + if (upgrade.isStarter) { + mod.badReason = "starter"; + } else if (upgrade.isFrivolous) { + mod.badReason = "frivolous"; + } else if (upgrade.upgradeEntries) { + mod.badReason = "notraw"; } + res.mods.push(mod); } for (const [uniqueName, upgrade] of Object.entries(ExportAvionics)) { res.mods.push({ @@ -151,13 +156,14 @@ const getItemListsController: RequestHandler = (req, response) => { }); } for (const [uniqueName, arcane] of Object.entries(ExportArcanes)) { - res.mods.push({ + const mod: ListedItem = { uniqueName, name: getString(arcane.name, lang) - }); + }; if (arcane.isFrivolous) { - badItems[uniqueName] = true; + mod.badReason = "frivolous"; } + res.mods.push(mod); } for (const [uniqueName, syndicate] of Object.entries(ExportSyndicates)) { res.Syndicates.push({ @@ -167,7 +173,6 @@ 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 1c55cf4d7..a73097db3 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -207,11 +207,16 @@ function fetchItemList() { document.getElementById("changeSyndicate").appendChild(option); itemMap[item.uniqueName] = { ...item, type }; }); - } else if (type != "badItems") { + } else { items.forEach(item => { - if (item.uniqueName in data.badItems) { - item.name += " " + loc("code_badItem"); - } else if (item.uniqueName.substr(0, 18) != "/Lotus/Types/Game/") { + if ("badReason" in item) { + if (item.badReason == "starter") { + item.name = loc("code_starter").split("|MOD|").join(item.name); + } else { + item.name += " " + loc("code_badItem"); + } + } + if (item.uniqueName.substr(0, 18) != "/Lotus/Types/Game/" && item.badReason != "notraw") { const option = document.createElement("option"); option.setAttribute("data-key", item.uniqueName); option.value = item.name; diff --git a/static/webui/translations/en.js b/static/webui/translations/en.js index 750dfc944..f69a8fd3f 100644 --- a/static/webui/translations/en.js +++ b/static/webui/translations/en.js @@ -18,6 +18,7 @@ dict = { code_kDrive: `K-Drive`, code_legendaryCore: `Legendary Core`, code_traumaticPeculiar: `Traumatic Peculiar`, + code_starter: `|MOD| (Flawed)`, code_badItem: `(Imposter)`, code_maxRank: `Max Rank`, code_rename: `Rename`, diff --git a/static/webui/translations/ru.js b/static/webui/translations/ru.js index b85344c15..d2cc9a025 100644 --- a/static/webui/translations/ru.js +++ b/static/webui/translations/ru.js @@ -19,6 +19,7 @@ dict = { code_kDrive: `К-Драйв`, code_legendaryCore: `Легендарное ядро`, code_traumaticPeculiar: `Травмирующая Странность`, + code_starter: `[UNTRANSLATED] |MOD| (Flawed)`, code_badItem: `(Самозванец)`, code_maxRank: `Максимальный ранг`, code_rename: `Переименовать`,