XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

feat(webui): unlock level cap (#2799)

Closes #2620 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2799 Reviewed-by: Sainan <63328889+sainan@users.noreply.github.com> Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>

3d8aa608
AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
提交于

代码差异

11 个文件 +74 -14
Modified src/controllers/custom/getItemListsController.ts +5 -10
@@ -37,10 +37,10 @@ interface ListedItem {
37 37 chainLength?: number;
38 38 parazon?: boolean;
39 39 alwaysAvailable?: boolean;
40 maxLevelCap?: number;
40 41 }
41 42
42 43 interface ItemLists {
43 uniqueLevelCaps: Record<string, number>;
44 44 Suits: ListedItem[];
45 45 LongGuns: ListedItem[];
46 46 Melee: ListedItem[];
@@ -83,7 +83,6 @@ const toTitleCase = (str: string): string => {
83 83 const getItemListsController: RequestHandler = (req, response) => {
84 84 const lang = getDict(typeof req.query.lang == "string" ? req.query.lang : "en");
85 85 const res: ItemLists = {
86 uniqueLevelCaps: {},
87 86 Suits: [],
88 87 LongGuns: [],
89 88 Melee: [],
@@ -144,7 +143,8 @@ const getItemListsController: RequestHandler = (req, response) => {
144 143 res[item.productCategory].push({
145 144 uniqueName,
146 145 name: getString(item.name, lang),
147 exalted: item.exalted
146 exalted: item.exalted,
147 maxLevelCap: item.maxLevelCap
148 148 });
149 149 item.abilities.forEach(ability => {
150 150 res.Abilities.push({
@@ -152,9 +152,6 @@ const getItemListsController: RequestHandler = (req, response) => {
152 152 name: getString(ability.name || uniqueName, lang)
153 153 });
154 154 });
155 if (item.maxLevelCap) {
156 res.uniqueLevelCaps[uniqueName] = item.maxLevelCap;
157 }
158 155 }
159 156 for (const [uniqueName, item] of Object.entries(ExportSentinels)) {
160 157 if (item.productCategory == "Sentinels" || item.productCategory == "KubrowPets") {
@@ -195,7 +192,8 @@ const getItemListsController: RequestHandler = (req, response) => {
195 192 ) {
196 193 res[item.productCategory].push({
197 194 uniqueName,
198 name: getString(item.name, lang)
195 name: getString(item.name, lang),
196 maxLevelCap: item.maxLevelCap
199 197 });
200 198 }
201 199 } else if (!item.excludeFromCodex) {
@@ -204,9 +202,6 @@ const getItemListsController: RequestHandler = (req, response) => {
204 202 name: getString(item.name, lang)
205 203 });
206 204 }
207 if (item.maxLevelCap) {
208 res.uniqueLevelCaps[uniqueName] = item.maxLevelCap;
209 }
210 205 }
211 206 for (const [uniqueName, item] of Object.entries(ExportResources)) {
212 207 let name = getString(item.name, lang);
Added src/controllers/custom/unlockLevelCapController.ts +25 -0
@@ -0,0 +1,25 @@
1 import type { RequestHandler } from "express";
2 import { getAccountIdForRequest } from "../../services/loginService.ts";
3 import { broadcastInventoryUpdate } from "../../services/wsService.ts";
4 import { getInventory } from "../../services/inventoryService.ts";
5 import type { TEquipmentKey } from "../../types/inventoryTypes/inventoryTypes.ts";
6
7 export const unlockLevelCapController: RequestHandler = async (req, res) => {
8 const accountId = await getAccountIdForRequest(req);
9 const data = req.body as IunlockLevelCapRequest;
10 const inventory = await getInventory(accountId, data.Category);
11 const equipment = inventory[data.Category].id(data.ItemId)!;
12
13 equipment.Polarized ??= 0;
14 equipment.Polarized = data.Polarized;
15
16 await inventory.save();
17 res.end();
18 broadcastInventoryUpdate(req);
19 };
20
21 interface IunlockLevelCapRequest {
22 Category: TEquipmentKey;
23 ItemId: string;
24 Polarized: number;
25 }
Modified src/routes/custom.ts +2 -0
@@ -41,6 +41,7 @@ import { manageQuestsController } from "../controllers/custom/manageQuestsContro
41 41 import { setEvolutionProgressController } from "../controllers/custom/setEvolutionProgressController.ts";
42 42 import { setBoosterController } from "../controllers/custom/setBoosterController.ts";
43 43 import { updateFingerprintController } from "../controllers/custom/updateFingerprintController.ts";
44 import { unlockLevelCapController } from "../controllers/custom/unlockLevelCapController.ts";
44 45 import { changeModularPartsController } from "../controllers/custom/changeModularPartsController.ts";
45 46 import { editSuitInvigorationUpgradeController } from "../controllers/custom/editSuitInvigorationUpgradeController.ts";
46 47 import { setAccountCheatController } from "../controllers/custom/setAccountCheatController.ts";
@@ -89,6 +90,7 @@ customRouter.post("/manageQuests", manageQuestsController);
89 90 customRouter.post("/setEvolutionProgress", setEvolutionProgressController);
90 91 customRouter.post("/setBooster", setBoosterController);
91 92 customRouter.post("/updateFingerprint", updateFingerprintController);
93 customRouter.post("/unlockLevelCap", unlockLevelCapController);
92 94 customRouter.post("/changeModularParts", changeModularPartsController);
93 95 customRouter.post("/editSuitInvigorationUpgrade", editSuitInvigorationUpgradeController);
94 96 customRouter.post("/setAccountCheat", setAccountCheatController);
Modified static/webui/script.js +35 -4
@@ -311,7 +311,6 @@ const permanentEvolutionWeapons = new Set([
311 311 "/Lotus/Weapons/Tenno/Zariman/Melee/HeavyScythe/ZarimanHeavyScythe/ZarimanHeavyScytheWeapon"
312 312 ]);
313 313
314 let uniqueLevelCaps = {};
315 314 function fetchItemList() {
316 315 window.itemListPromise = new Promise(resolve => {
317 316 const req = $.get("/custom/getItemLists?lang=" + window.lang);
@@ -558,8 +557,6 @@ function fetchItemList() {
558 557 option.textContent = item.name;
559 558 document.getElementById("worldState.varziaOverride").appendChild(option);
560 559 });
561 } else if (type == "uniqueLevelCaps") {
562 uniqueLevelCaps = items;
563 560 } else if (type == "Syndicates") {
564 561 items.forEach(item => {
565 562 if (item.uniqueName === "ConclaveSyndicate") {
@@ -791,7 +788,7 @@ function updateInventory() {
791 788 const td = document.createElement("td");
792 789 td.classList = "text-end text-nowrap";
793 790
794 let maxXP = Math.pow(uniqueLevelCaps[item.ItemType] ?? 30, 2) * 1000;
791 let maxXP = Math.pow(itemMap[item.ItemType].maxLevelCap ?? 30, 2) * 1000;
795 792 if (
796 793 category != "Suits" &&
797 794 category != "SpaceSuits" &&
@@ -817,6 +814,24 @@ function updateInventory() {
817 814 }
818 815 }
819 816 }
817 if (
818 itemMap[item.ItemType].maxLevelCap > 30 &&
819 (item.Polarized ?? 0) < (itemMap[item.ItemType].maxLevelCap - 30) / 2
820 ) {
821 const a = document.createElement("a");
822 a.href = "#";
823 a.onclick = function (event) {
824 event.preventDefault();
825 unlockLevelCap(
826 category,
827 item.ItemId.$oid,
828 (itemMap[item.ItemType].maxLevelCap - 30) / 2
829 );
830 };
831 a.title = loc("code_unlockLevelCap");
832 a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--!Font Awesome Free v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M48 195.8l209.2 86.1c9.8 4 20.2 6.1 30.8 6.1s21-2.1 30.8-6.1l242.4-99.8c9-3.7 14.8-12.4 14.8-22.1s-5.8-18.4-14.8-22.1L318.8 38.1C309 34.1 298.6 32 288 32s-21 2.1-30.8 6.1L14.8 137.9C5.8 141.6 0 150.3 0 160L0 456c0 13.3 10.7 24 24 24s24-10.7 24-24l0-260.2zm48 71.7L96 384c0 53 86 96 192 96s192-43 192-96l0-116.6-142.9 58.9c-15.6 6.4-32.2 9.7-49.1 9.7s-33.5-3.3-49.1-9.7L96 267.4z"/></svg>`;
833 td.appendChild(a);
834 }
820 835 if (item.XP < maxXP || anyExaltedMissingXP) {
821 836 const a = document.createElement("a");
822 837 a.href = "#";
@@ -2759,6 +2774,22 @@ function gildEquipment(category, oid) {
2759 2774 });
2760 2775 }
2761 2776
2777 function unlockLevelCap(category, oid, formas) {
2778 revalidateAuthz().then(() => {
2779 $.post({
2780 url: "/custom/unlockLevelCap?" + window.authz,
2781 contentType: "application/json",
2782 data: JSON.stringify({
2783 Category: category,
2784 ItemId: oid,
2785 Polarized: formas
2786 })
2787 }).done(function () {
2788 updateInventory();
2789 });
2790 });
2791 }
2792
2762 2793 function maturePet(oid, revert) {
2763 2794 revalidateAuthz().then(() => {
2764 2795 $.post({
Modified static/webui/translations/de.js +1 -0
@@ -45,6 +45,7 @@ dict = {
45 45 code_rank: `Rang`,
46 46 code_rankUp: `Rang erhöhen`,
47 47 code_rankDown: `Rang verringern`,
48 code_unlockLevelCap: `[UNTRANSLATED] Unlock level cap`,
48 49 code_count: `Anzahl`,
49 50 code_focusAllUnlocked: `Alle Fokus-Schulen sind bereits freigeschaltet.`,
50 51 code_focusUnlocked: `|COUNT| neue Fokus-Schulen freigeschaltet! Ein Inventar-Update wird benötigt, damit die Änderungen im Spiel sichtbar werden. Die Sternenkarte zu besuchen, sollte der einfachste Weg sein, dies auszulösen.`,
Modified static/webui/translations/en.js +1 -0
@@ -44,6 +44,7 @@ dict = {
44 44 code_rank: `Rank`,
45 45 code_rankUp: `Rank up`,
46 46 code_rankDown: `Rank down`,
47 code_unlockLevelCap: `Unlock level cap`,
47 48 code_count: `Count`,
48 49 code_focusAllUnlocked: `All focus schools are already unlocked.`,
49 50 code_focusUnlocked: `Unlocked |COUNT| new focus schools! An inventory update will be needed for the changes to be reflected in-game. Visiting the navigation should be the easiest way to trigger that.`,
Modified static/webui/translations/es.js +1 -0
@@ -45,6 +45,7 @@ dict = {
45 45 code_rank: `Rango`,
46 46 code_rankUp: `Subir de rango`,
47 47 code_rankDown: `Bajar de rango`,
48 code_unlockLevelCap: `[UNTRANSLATED] Unlock level cap`,
48 49 code_count: `Cantidad`,
49 50 code_focusAllUnlocked: `Todas las escuelas de enfoque ya están desbloqueadas.`,
50 51 code_focusUnlocked: `¡Desbloqueadas |COUNT| nuevas escuelas de enfoque! Se necesita una actualización del inventario para reflejar los cambios en el juego. Visitar la navegación debería ser la forma más sencilla de activarlo.`,
Modified static/webui/translations/fr.js +1 -0
@@ -45,6 +45,7 @@ dict = {
45 45 code_rank: `Rang`,
46 46 code_rankUp: `Monter de rang`,
47 47 code_rankDown: `Baisser de rang`,
48 code_unlockLevelCap: `[UNTRANSLATED] Unlock level cap`,
48 49 code_count: `Quantité`,
49 50 code_focusAllUnlocked: `Les écoles de Focus sont déjà déverrouillées.`,
50 51 code_focusUnlocked: `|COUNT| écoles de Focus déverrouillées ! Synchronisation de l'inventaire nécessaire.`,
Modified static/webui/translations/ru.js +1 -0
@@ -45,6 +45,7 @@ dict = {
45 45 code_rank: `Ранг`,
46 46 code_rankUp: `Повысить ранг`,
47 47 code_rankDown: `Понизить ранг`,
48 code_unlockLevelCap: `[UNTRANSLATED] Unlock level cap`,
48 49 code_count: `Количество`,
49 50 code_focusAllUnlocked: `Все школы Фокуса уже разблокированы.`,
50 51 code_focusUnlocked: `Разблокировано |COUNT| новых школ Фокуса! Для отображения изменений в игре потребуется обновление инвентаря. Посещение навигации — самый простой способ этого добиться.`,
Modified static/webui/translations/uk.js +1 -0
@@ -45,6 +45,7 @@ dict = {
45 45 code_rank: `Рівень`,
46 46 code_rankUp: `Підвищити рівень`,
47 47 code_rankDown: `Понизити рівень`,
48 code_unlockLevelCap: `[UNTRANSLATED] Unlock level cap`,
48 49 code_count: `Кількість`,
49 50 code_focusAllUnlocked: `Всі школи Фокусу вже розблоковані.`,
50 51 code_focusUnlocked: `Розблоковано |COUNT| нових шкіл Фокусу! Для відображення змін в грі знадобиться оновлення спорядження. Відвідування навігації — найпростіший спосіб цього досягти.`,
Modified static/webui/translations/zh.js +1 -0
@@ -45,6 +45,7 @@ dict = {
45 45 code_rank: `等级`,
46 46 code_rankUp: `等级提升`,
47 47 code_rankDown: `等级下降`,
48 code_unlockLevelCap: `[UNTRANSLATED] Unlock level cap`,
48 49 code_count: `数量`,
49 50 code_focusAllUnlocked: `所有专精学派均已解锁`,
50 51 code_focusUnlocked: `已解锁 |COUNT| 个新专精学派!需要游戏内仓库更新才能生效,您可以通过访问星图来触发仓库更新.`,