feat(webui): unlock level cap #2799
@ -37,10 +37,10 @@ interface ListedItem {
 | 
			
		||||
    chainLength?: number;
 | 
			
		||||
    parazon?: boolean;
 | 
			
		||||
    alwaysAvailable?: boolean;
 | 
			
		||||
    maxLevelCap?: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface ItemLists {
 | 
			
		||||
    uniqueLevelCaps: Record<string, number>;
 | 
			
		||||
    Suits: ListedItem[];
 | 
			
		||||
    LongGuns: ListedItem[];
 | 
			
		||||
    Melee: ListedItem[];
 | 
			
		||||
@ -83,7 +83,6 @@ const toTitleCase = (str: string): string => {
 | 
			
		||||
const getItemListsController: RequestHandler = (req, response) => {
 | 
			
		||||
    const lang = getDict(typeof req.query.lang == "string" ? req.query.lang : "en");
 | 
			
		||||
    const res: ItemLists = {
 | 
			
		||||
        uniqueLevelCaps: {},
 | 
			
		||||
        Suits: [],
 | 
			
		||||
        LongGuns: [],
 | 
			
		||||
        Melee: [],
 | 
			
		||||
@ -144,7 +143,8 @@ const getItemListsController: RequestHandler = (req, response) => {
 | 
			
		||||
        res[item.productCategory].push({
 | 
			
		||||
            uniqueName,
 | 
			
		||||
            name: getString(item.name, lang),
 | 
			
		||||
            exalted: item.exalted
 | 
			
		||||
            exalted: item.exalted,
 | 
			
		||||
            maxLevelCap: item.maxLevelCap
 | 
			
		||||
        });
 | 
			
		||||
        item.abilities.forEach(ability => {
 | 
			
		||||
            res.Abilities.push({
 | 
			
		||||
@ -152,9 +152,6 @@ const getItemListsController: RequestHandler = (req, response) => {
 | 
			
		||||
                name: getString(ability.name || uniqueName, lang)
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
        if (item.maxLevelCap) {
 | 
			
		||||
            res.uniqueLevelCaps[uniqueName] = item.maxLevelCap;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    for (const [uniqueName, item] of Object.entries(ExportSentinels)) {
 | 
			
		||||
        if (item.productCategory == "Sentinels" || item.productCategory == "KubrowPets") {
 | 
			
		||||
@ -195,7 +192,8 @@ const getItemListsController: RequestHandler = (req, response) => {
 | 
			
		||||
            ) {
 | 
			
		||||
                res[item.productCategory].push({
 | 
			
		||||
                    uniqueName,
 | 
			
		||||
                    name: getString(item.name, lang)
 | 
			
		||||
                    name: getString(item.name, lang),
 | 
			
		||||
                    maxLevelCap: item.maxLevelCap
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        } else if (!item.excludeFromCodex) {
 | 
			
		||||
@ -204,9 +202,6 @@ const getItemListsController: RequestHandler = (req, response) => {
 | 
			
		||||
                name: getString(item.name, lang)
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        if (item.maxLevelCap) {
 | 
			
		||||
            res.uniqueLevelCaps[uniqueName] = item.maxLevelCap;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    for (const [uniqueName, item] of Object.entries(ExportResources)) {
 | 
			
		||||
        let name = getString(item.name, lang);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										25
									
								
								src/controllers/custom/unlockLevelCupController.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/controllers/custom/unlockLevelCupController.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
			
		||||
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
 | 
			
		||||
import { getInventory } from "../../services/inventoryService.ts";
 | 
			
		||||
import type { TEquipmentKey } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
			
		||||
 | 
			
		||||
export const unlockLevelCupController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const data = req.body as IUnlockLevelCupRequest;
 | 
			
		||||
    const inventory = await getInventory(accountId, data.Category);
 | 
			
		||||
    const equipment = inventory[data.Category].id(data.ItemId)!;
 | 
			
		||||
 | 
			
		||||
    equipment.Polarized ??= 0;
 | 
			
		||||
    equipment.Polarized = data.Polarized;
 | 
			
		||||
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.end();
 | 
			
		||||
    broadcastInventoryUpdate(req);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
interface IUnlockLevelCupRequest {
 | 
			
		||||
    Category: TEquipmentKey;
 | 
			
		||||
    ItemId: string;
 | 
			
		||||
    Polarized: number;
 | 
			
		||||
}
 | 
			
		||||
@ -41,6 +41,7 @@ import { manageQuestsController } from "../controllers/custom/manageQuestsContro
 | 
			
		||||
import { setEvolutionProgressController } from "../controllers/custom/setEvolutionProgressController.ts";
 | 
			
		||||
import { setBoosterController } from "../controllers/custom/setBoosterController.ts";
 | 
			
		||||
import { updateFingerprintController } from "../controllers/custom/updateFingerprintController.ts";
 | 
			
		||||
import { unlockLevelCupController } from "../controllers/custom/unlockLevelCupController.ts";
 | 
			
		||||
import { changeModularPartsController } from "../controllers/custom/changeModularPartsController.ts";
 | 
			
		||||
import { editSuitInvigorationUpgradeController } from "../controllers/custom/editSuitInvigorationUpgradeController.ts";
 | 
			
		||||
import { setAccountCheatController } from "../controllers/custom/setAccountCheatController.ts";
 | 
			
		||||
@ -89,6 +90,7 @@ customRouter.post("/manageQuests", manageQuestsController);
 | 
			
		||||
customRouter.post("/setEvolutionProgress", setEvolutionProgressController);
 | 
			
		||||
customRouter.post("/setBooster", setBoosterController);
 | 
			
		||||
customRouter.post("/updateFingerprint", updateFingerprintController);
 | 
			
		||||
customRouter.post("/unlockLevelCup", unlockLevelCupController);
 | 
			
		||||
customRouter.post("/changeModularParts", changeModularPartsController);
 | 
			
		||||
customRouter.post("/editSuitInvigorationUpgrade", editSuitInvigorationUpgradeController);
 | 
			
		||||
customRouter.post("/setAccountCheat", setAccountCheatController);
 | 
			
		||||
 | 
			
		||||
@ -311,7 +311,6 @@ const permanentEvolutionWeapons = new Set([
 | 
			
		||||
    "/Lotus/Weapons/Tenno/Zariman/Melee/HeavyScythe/ZarimanHeavyScythe/ZarimanHeavyScytheWeapon"
 | 
			
		||||
]);
 | 
			
		||||
 | 
			
		||||
let uniqueLevelCaps = {};
 | 
			
		||||
function fetchItemList() {
 | 
			
		||||
    window.itemListPromise = new Promise(resolve => {
 | 
			
		||||
        const req = $.get("/custom/getItemLists?lang=" + window.lang);
 | 
			
		||||
@ -558,8 +557,6 @@ function fetchItemList() {
 | 
			
		||||
                        option.textContent = item.name;
 | 
			
		||||
                        document.getElementById("worldState.varziaOverride").appendChild(option);
 | 
			
		||||
                    });
 | 
			
		||||
                } else if (type == "uniqueLevelCaps") {
 | 
			
		||||
                    uniqueLevelCaps = items;
 | 
			
		||||
                } else if (type == "Syndicates") {
 | 
			
		||||
                    items.forEach(item => {
 | 
			
		||||
                        if (item.uniqueName === "ConclaveSyndicate") {
 | 
			
		||||
@ -791,7 +788,7 @@ function updateInventory() {
 | 
			
		||||
                            const td = document.createElement("td");
 | 
			
		||||
                            td.classList = "text-end text-nowrap";
 | 
			
		||||
 | 
			
		||||
                            let maxXP = Math.pow(uniqueLevelCaps[item.ItemType] ?? 30, 2) * 1000;
 | 
			
		||||
                            let maxXP = Math.pow(itemMap[item.ItemType].maxLevelCap ?? 30, 2) * 1000;
 | 
			
		||||
                            if (
 | 
			
		||||
                                category != "Suits" &&
 | 
			
		||||
                                category != "SpaceSuits" &&
 | 
			
		||||
@ -817,6 +814,24 @@ function updateInventory() {
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            if (
 | 
			
		||||
                                itemMap[item.ItemType].maxLevelCap > 30 &&
 | 
			
		||||
                                (item.Polarized ?? 0) < (itemMap[item.ItemType].maxLevelCap - 30) / 2
 | 
			
		||||
                            ) {
 | 
			
		||||
                                const a = document.createElement("a");
 | 
			
		||||
                                a.href = "#";
 | 
			
		||||
                                a.onclick = function (event) {
 | 
			
		||||
                                    event.preventDefault();
 | 
			
		||||
                                    unlockLevelCup(
 | 
			
		||||
                                        category,
 | 
			
		||||
                                        item.ItemId.$oid,
 | 
			
		||||
                                        (itemMap[item.ItemType].maxLevelCap - 30) / 2
 | 
			
		||||
                                    );
 | 
			
		||||
                                };
 | 
			
		||||
                                a.title = loc("code_unlockLevelCap");
 | 
			
		||||
                                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>`;
 | 
			
		||||
                                td.appendChild(a);
 | 
			
		||||
                            }
 | 
			
		||||
                            if (item.XP < maxXP || anyExaltedMissingXP) {
 | 
			
		||||
                                const a = document.createElement("a");
 | 
			
		||||
                                a.href = "#";
 | 
			
		||||
@ -2759,6 +2774,22 @@ function gildEquipment(category, oid) {
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function unlockLevelCup(category, oid, formas) {
 | 
			
		||||
    revalidateAuthz().then(() => {
 | 
			
		||||
        $.post({
 | 
			
		||||
            url: "/custom/unlockLevelCup?" + window.authz,
 | 
			
		||||
            contentType: "application/json",
 | 
			
		||||
            data: JSON.stringify({
 | 
			
		||||
                Category: category,
 | 
			
		||||
                ItemId: oid,
 | 
			
		||||
                Polarized: formas
 | 
			
		||||
            })
 | 
			
		||||
        }).done(function () {
 | 
			
		||||
            updateInventory();
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function maturePet(oid, revert) {
 | 
			
		||||
    revalidateAuthz().then(() => {
 | 
			
		||||
        $.post({
 | 
			
		||||
 | 
			
		||||
@ -45,6 +45,7 @@ dict = {
 | 
			
		||||
    code_rank: `Rang`,
 | 
			
		||||
    code_rankUp: `Rang erhöhen`,
 | 
			
		||||
    code_rankDown: `Rang verringern`,
 | 
			
		||||
    code_unlockLevelCap: `[UNTRANSLATED] Unlock level cap`,
 | 
			
		||||
    code_count: `Anzahl`,
 | 
			
		||||
    code_focusAllUnlocked: `Alle Fokus-Schulen sind bereits freigeschaltet.`,
 | 
			
		||||
    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.`,
 | 
			
		||||
 | 
			
		||||
@ -44,6 +44,7 @@ dict = {
 | 
			
		||||
    code_rank: `Rank`,
 | 
			
		||||
    code_rankUp: `Rank up`,
 | 
			
		||||
    code_rankDown: `Rank down`,
 | 
			
		||||
    code_unlockLevelCap: `Unlock level cap`,
 | 
			
		||||
    code_count: `Count`,
 | 
			
		||||
    code_focusAllUnlocked: `All focus schools are already unlocked.`,
 | 
			
		||||
    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.`,
 | 
			
		||||
 | 
			
		||||
@ -45,6 +45,7 @@ dict = {
 | 
			
		||||
    code_rank: `Rango`,
 | 
			
		||||
    code_rankUp: `Subir de rango`,
 | 
			
		||||
    code_rankDown: `Bajar de rango`,
 | 
			
		||||
    code_unlockLevelCap: `[UNTRANSLATED] Unlock level cap`,
 | 
			
		||||
    code_count: `Cantidad`,
 | 
			
		||||
    code_focusAllUnlocked: `Todas las escuelas de enfoque ya están desbloqueadas.`,
 | 
			
		||||
    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.`,
 | 
			
		||||
 | 
			
		||||
@ -45,6 +45,7 @@ dict = {
 | 
			
		||||
    code_rank: `Rang`,
 | 
			
		||||
    code_rankUp: `Monter de rang`,
 | 
			
		||||
    code_rankDown: `Baisser de rang`,
 | 
			
		||||
    code_unlockLevelCap: `[UNTRANSLATED] Unlock level cap`,
 | 
			
		||||
    code_count: `Quantité`,
 | 
			
		||||
    code_focusAllUnlocked: `Les écoles de Focus sont déjà déverrouillées.`,
 | 
			
		||||
    code_focusUnlocked: `|COUNT| écoles de Focus déverrouillées ! Synchronisation de l'inventaire nécessaire.`,
 | 
			
		||||
 | 
			
		||||
@ -45,6 +45,7 @@ dict = {
 | 
			
		||||
    code_rank: `Ранг`,
 | 
			
		||||
    code_rankUp: `Повысить ранг`,
 | 
			
		||||
    code_rankDown: `Понизить ранг`,
 | 
			
		||||
    code_unlockLevelCap: `[UNTRANSLATED] Unlock level cap`,
 | 
			
		||||
    code_count: `Количество`,
 | 
			
		||||
    code_focusAllUnlocked: `Все школы Фокуса уже разблокированы.`,
 | 
			
		||||
    code_focusUnlocked: `Разблокировано |COUNT| новых школ Фокуса! Для отображения изменений в игре потребуется обновление инвентаря. Посещение навигации — самый простой способ этого добиться.`,
 | 
			
		||||
 | 
			
		||||
@ -45,6 +45,7 @@ dict = {
 | 
			
		||||
    code_rank: `Рівень`,
 | 
			
		||||
    code_rankUp: `Підвищити рівень`,
 | 
			
		||||
    code_rankDown: `Понизити рівень`,
 | 
			
		||||
    code_unlockLevelCap: `[UNTRANSLATED] Unlock level cap`,
 | 
			
		||||
    code_count: `Кількість`,
 | 
			
		||||
    code_focusAllUnlocked: `Всі школи Фокусу вже розблоковані.`,
 | 
			
		||||
    code_focusUnlocked: `Розблоковано |COUNT| нових шкіл Фокусу! Для відображення змін в грі знадобиться оновлення спорядження. Відвідування навігації — найпростіший спосіб цього досягти.`,
 | 
			
		||||
 | 
			
		||||
@ -45,6 +45,7 @@ dict = {
 | 
			
		||||
    code_rank: `等级`,
 | 
			
		||||
    code_rankUp: `等级提升`,
 | 
			
		||||
    code_rankDown: `等级下降`,
 | 
			
		||||
    code_unlockLevelCap: `[UNTRANSLATED] Unlock level cap`,
 | 
			
		||||
    code_count: `数量`,
 | 
			
		||||
    code_focusAllUnlocked: `所有专精学派均已解锁`,
 | 
			
		||||
    code_focusUnlocked: `已解锁 |COUNT| 个新专精学派!需要游戏内仓库更新才能生效,您可以通过访问星图来触发仓库更新.`,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user