feat(webui): gild action for modular equipment #1375
							
								
								
									
										23
									
								
								src/controllers/custom/gildEquipmentController.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/controllers/custom/gildEquipmentController.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					import { getInventory } from "@/src/services/inventoryService";
 | 
				
			||||||
 | 
					import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
				
			||||||
 | 
					import { EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
				
			||||||
 | 
					import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const gildEquipmentController: RequestHandler = async (req, res) => {
 | 
				
			||||||
 | 
					    const accountId = await getAccountIdForRequest(req);
 | 
				
			||||||
 | 
					    const request = req.body as IGildEquipmentRequest;
 | 
				
			||||||
 | 
					    const inventory = await getInventory(accountId, request.Category);
 | 
				
			||||||
 | 
					    const weapon = inventory[request.Category].id(request.ItemId);
 | 
				
			||||||
 | 
					    if (weapon) {
 | 
				
			||||||
 | 
					        weapon.Features ??= 0;
 | 
				
			||||||
 | 
					        weapon.Features |= EquipmentFeatures.GILDED;
 | 
				
			||||||
 | 
					        await inventory.save();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    res.end();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IGildEquipmentRequest = {
 | 
				
			||||||
 | 
					    ItemId: string;
 | 
				
			||||||
 | 
					    Category: TEquipmentKey;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -16,6 +16,7 @@ import { createMessageController } from "@/src/controllers/custom/createMessageC
 | 
				
			|||||||
import { addCurrencyController } from "../controllers/custom/addCurrencyController";
 | 
					import { addCurrencyController } from "../controllers/custom/addCurrencyController";
 | 
				
			||||||
import { addItemsController } from "@/src/controllers/custom/addItemsController";
 | 
					import { addItemsController } from "@/src/controllers/custom/addItemsController";
 | 
				
			||||||
import { addXpController } from "@/src/controllers/custom/addXpController";
 | 
					import { addXpController } from "@/src/controllers/custom/addXpController";
 | 
				
			||||||
 | 
					import { gildEquipmentController } from "@/src/controllers/custom/gildEquipmentController";
 | 
				
			||||||
import { importController } from "@/src/controllers/custom/importController";
 | 
					import { importController } from "@/src/controllers/custom/importController";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { getConfigDataController } from "@/src/controllers/custom/getConfigDataController";
 | 
					import { getConfigDataController } from "@/src/controllers/custom/getConfigDataController";
 | 
				
			||||||
@ -40,6 +41,7 @@ customRouter.post("/createMessage", createMessageController);
 | 
				
			|||||||
customRouter.post("/addCurrency", addCurrencyController);
 | 
					customRouter.post("/addCurrency", addCurrencyController);
 | 
				
			||||||
customRouter.post("/addItems", addItemsController);
 | 
					customRouter.post("/addItems", addItemsController);
 | 
				
			||||||
customRouter.post("/addXp", addXpController);
 | 
					customRouter.post("/addXp", addXpController);
 | 
				
			||||||
 | 
					customRouter.post("/gildEquipment", gildEquipmentController);
 | 
				
			||||||
customRouter.post("/import", importController);
 | 
					customRouter.post("/import", importController);
 | 
				
			||||||
customRouter.post("/manageQuests", manageQuestsController);
 | 
					customRouter.post("/manageQuests", manageQuestsController);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -255,6 +255,20 @@ function updateInventory() {
 | 
				
			|||||||
        window.itemListPromise.then(itemMap => {
 | 
					        window.itemListPromise.then(itemMap => {
 | 
				
			||||||
            window.didInitialInventoryUpdate = true;
 | 
					            window.didInitialInventoryUpdate = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            const modularWeapons = [
 | 
				
			||||||
 | 
					                "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimary",
 | 
				
			||||||
 | 
					                "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam",
 | 
				
			||||||
 | 
					                "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryLauncher",
 | 
				
			||||||
 | 
					                "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryShotgun",
 | 
				
			||||||
 | 
					                "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimarySniper",
 | 
				
			||||||
 | 
					                "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary",
 | 
				
			||||||
 | 
					                "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam",
 | 
				
			||||||
 | 
					                "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun",
 | 
				
			||||||
 | 
					                "/Lotus/Weapons/Ostron/Melee/LotusModularWeapon",
 | 
				
			||||||
 | 
					                "/Lotus/Weapons/Sentients/OperatorAmplifiers/OperatorAmpWeapon",
 | 
				
			||||||
 | 
					                "/Lotus/Types/Vehicles/Hoverboard/HoverboardSuit"
 | 
				
			||||||
 | 
					            ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Populate inventory route
 | 
					            // Populate inventory route
 | 
				
			||||||
            ["RegularCredits", "PremiumCredits", "FusionPoints", "PrimeTokens"].forEach(currency => {
 | 
					            ["RegularCredits", "PremiumCredits", "FusionPoints", "PrimeTokens"].forEach(currency => {
 | 
				
			||||||
                document.getElementById(currency + "-owned").textContent = loc("currency_owned")
 | 
					                document.getElementById(currency + "-owned").textContent = loc("currency_owned")
 | 
				
			||||||
@ -341,6 +355,17 @@ function updateInventory() {
 | 
				
			|||||||
                            a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M214.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 141.2V448c0 17.7 14.3 32 32 32s32-14.3 32-32V141.2L329.4 246.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-160-160z"/></svg>`;
 | 
					                            a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M214.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 141.2V448c0 17.7 14.3 32 32 32s32-14.3 32-32V141.2L329.4 246.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-160-160z"/></svg>`;
 | 
				
			||||||
                            td.appendChild(a);
 | 
					                            td.appendChild(a);
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					                        if (!(item.Features & 8) && modularWeapons.includes(item.ItemType)) {
 | 
				
			||||||
 | 
					                            const a = document.createElement("a");
 | 
				
			||||||
 | 
					                            a.href = "#";
 | 
				
			||||||
 | 
					                            a.onclick = function (event) {
 | 
				
			||||||
 | 
					                                event.preventDefault();
 | 
				
			||||||
 | 
					                                gildEquipment(category, item.ItemId.$oid);
 | 
				
			||||||
 | 
					                            };
 | 
				
			||||||
 | 
					                            a.title = loc("code_gild");
 | 
				
			||||||
 | 
					                            a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M316.9 18C311.6 7 300.4 0 288.1 0s-23.4 7-28.8 18L195 150.3 51.4 171.5c-12 1.8-22 10.2-25.7 21.7s-.7 24.2 7.9 32.7L137.8 329 113.2 474.7c-2 12 3 24.2 12.9 31.3s23 8 33.8 2.3l128.3-68.5 128.3 68.5c10.8 5.7 23.9 4.9 33.8-2.3s14.9-19.3 12.9-31.3L438.5 329 542.7 225.9c8.6-8.5 11.7-21.2 7.9-32.7s-13.7-19.9-25.7-21.7L381.2 150.3 316.9 18z"/></svg>`;
 | 
				
			||||||
 | 
					                            td.appendChild(a);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                        if (category == "Suits") {
 | 
					                        if (category == "Suits") {
 | 
				
			||||||
                            const a = document.createElement("a");
 | 
					                            const a = document.createElement("a");
 | 
				
			||||||
                            a.href = "/webui/powersuit/" + item.ItemId.$oid;
 | 
					                            a.href = "/webui/powersuit/" + item.ItemId.$oid;
 | 
				
			||||||
@ -806,6 +831,21 @@ function disposeOfItems(category, type, count) {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function gildEquipment(category, oid) {
 | 
				
			||||||
 | 
					    revalidateAuthz(() => {
 | 
				
			||||||
 | 
					        $.post({
 | 
				
			||||||
 | 
					            url: "/custom/gildEquipment?" + window.authz,
 | 
				
			||||||
 | 
					            contentType: "application/json",
 | 
				
			||||||
 | 
					            data: JSON.stringify({
 | 
				
			||||||
 | 
					                ItemId: oid,
 | 
				
			||||||
 | 
					                Category: category
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					        }).done(function () {
 | 
				
			||||||
 | 
					            updateInventory();
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function doAcquireMiscItems() {
 | 
					function doAcquireMiscItems() {
 | 
				
			||||||
    const uniqueName = getKey(document.getElementById("miscitem-type"));
 | 
					    const uniqueName = getKey(document.getElementById("miscitem-type"));
 | 
				
			||||||
    if (!uniqueName) {
 | 
					    if (!uniqueName) {
 | 
				
			||||||
 | 
				
			|||||||
@ -40,6 +40,7 @@ dict = {
 | 
				
			|||||||
    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.`,
 | 
					    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.`,
 | 
				
			||||||
    code_addModsConfirm: `Bist du sicher, dass du |COUNT| Mods zu deinem Account hinzufügen möchtest?`,
 | 
					    code_addModsConfirm: `Bist du sicher, dass du |COUNT| Mods zu deinem Account hinzufügen möchtest?`,
 | 
				
			||||||
    code_succImport: `Erfolgreich importiert.`,
 | 
					    code_succImport: `Erfolgreich importiert.`,
 | 
				
			||||||
 | 
					    code_gild: `[UNTRANSLATED] Gild`,
 | 
				
			||||||
    login_description: `Melde dich mit deinem OpenWF-Account an (denselben Angaben wie im Spiel, wenn du dich mit diesem Server verbindest).`,
 | 
					    login_description: `Melde dich mit deinem OpenWF-Account an (denselben Angaben wie im Spiel, wenn du dich mit diesem Server verbindest).`,
 | 
				
			||||||
    login_emailLabel: `E-Mail-Adresse`,
 | 
					    login_emailLabel: `E-Mail-Adresse`,
 | 
				
			||||||
    login_passwordLabel: `Passwort`,
 | 
					    login_passwordLabel: `Passwort`,
 | 
				
			||||||
 | 
				
			|||||||
@ -39,6 +39,7 @@ dict = {
 | 
				
			|||||||
    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.`,
 | 
					    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.`,
 | 
				
			||||||
    code_addModsConfirm: `Are you sure you want to add |COUNT| mods to your account?`,
 | 
					    code_addModsConfirm: `Are you sure you want to add |COUNT| mods to your account?`,
 | 
				
			||||||
    code_succImport: `Successfully imported.`,
 | 
					    code_succImport: `Successfully imported.`,
 | 
				
			||||||
 | 
					    code_gild: `Gild`,
 | 
				
			||||||
    login_description: `Login using your OpenWF account credentials (same as in-game when connecting to this server).`,
 | 
					    login_description: `Login using your OpenWF account credentials (same as in-game when connecting to this server).`,
 | 
				
			||||||
    login_emailLabel: `Email address`,
 | 
					    login_emailLabel: `Email address`,
 | 
				
			||||||
    login_passwordLabel: `Password`,
 | 
					    login_passwordLabel: `Password`,
 | 
				
			||||||
 | 
				
			|||||||
@ -40,6 +40,7 @@ dict = {
 | 
				
			|||||||
    code_focusUnlocked: `|COUNT| écoles de Focus déverrouillées ! Synchronisation de l'inventaire nécessaire.`,
 | 
					    code_focusUnlocked: `|COUNT| écoles de Focus déverrouillées ! Synchronisation de l'inventaire nécessaire.`,
 | 
				
			||||||
    code_addModsConfirm: `Ajouter |COUNT| mods à l'inventaire ?`,
 | 
					    code_addModsConfirm: `Ajouter |COUNT| mods à l'inventaire ?`,
 | 
				
			||||||
    code_succImport: `Importé.`,
 | 
					    code_succImport: `Importé.`,
 | 
				
			||||||
 | 
					    code_gild: `[UNTRANSLATED] Gild`,
 | 
				
			||||||
    login_description: `Connexion avec les informations de connexion OpenWF.`,
 | 
					    login_description: `Connexion avec les informations de connexion OpenWF.`,
 | 
				
			||||||
    login_emailLabel: `Email`,
 | 
					    login_emailLabel: `Email`,
 | 
				
			||||||
    login_passwordLabel: `Mot de passe`,
 | 
					    login_passwordLabel: `Mot de passe`,
 | 
				
			||||||
 | 
				
			|||||||
@ -40,6 +40,7 @@ dict = {
 | 
				
			|||||||
    code_focusUnlocked: `Разблокировано |COUNT| новых школ фокуса! Для отображения изменений в игре потребуется обновление инвентаря. Посещение навигации — самый простой способ этого добиться.`,
 | 
					    code_focusUnlocked: `Разблокировано |COUNT| новых школ фокуса! Для отображения изменений в игре потребуется обновление инвентаря. Посещение навигации — самый простой способ этого добиться.`,
 | 
				
			||||||
    code_addModsConfirm: `Вы уверены, что хотите добавить |COUNT| модов на ваш аккаунт?`,
 | 
					    code_addModsConfirm: `Вы уверены, что хотите добавить |COUNT| модов на ваш аккаунт?`,
 | 
				
			||||||
    code_succImport: `Успешно импортировано.`,
 | 
					    code_succImport: `Успешно импортировано.`,
 | 
				
			||||||
 | 
					    code_gild: `Улучшить`,
 | 
				
			||||||
    login_description: `Войдите, используя учетные данные OpenWF (те же, что и в игре при подключении к этому серверу).`,
 | 
					    login_description: `Войдите, используя учетные данные OpenWF (те же, что и в игре при подключении к этому серверу).`,
 | 
				
			||||||
    login_emailLabel: `Адрес электронной почты`,
 | 
					    login_emailLabel: `Адрес электронной почты`,
 | 
				
			||||||
    login_passwordLabel: `Пароль`,
 | 
					    login_passwordLabel: `Пароль`,
 | 
				
			||||||
 | 
				
			|||||||
@ -40,6 +40,7 @@ dict = {
 | 
				
			|||||||
    code_focusUnlocked: `已解锁 |COUNT| 个新专精学派!需要游戏内仓库更新才能生效,您可以通过访问星图来触发仓库更新。`,
 | 
					    code_focusUnlocked: `已解锁 |COUNT| 个新专精学派!需要游戏内仓库更新才能生效,您可以通过访问星图来触发仓库更新。`,
 | 
				
			||||||
    code_addModsConfirm: `确定要向账户添加 |COUNT| 张MOD吗?`,
 | 
					    code_addModsConfirm: `确定要向账户添加 |COUNT| 张MOD吗?`,
 | 
				
			||||||
    code_succImport: `导入成功。`,
 | 
					    code_succImport: `导入成功。`,
 | 
				
			||||||
 | 
					    code_gild: `[UNTRANSLATED] Gild`,
 | 
				
			||||||
    login_description: `使用您的 OpenWF 账户凭证登录(与游戏内连接本服务器时使用的昵称相同)。`,
 | 
					    login_description: `使用您的 OpenWF 账户凭证登录(与游戏内连接本服务器时使用的昵称相同)。`,
 | 
				
			||||||
    login_emailLabel: `电子邮箱`,
 | 
					    login_emailLabel: `电子邮箱`,
 | 
				
			||||||
    login_passwordLabel: `密码`,
 | 
					    login_passwordLabel: `密码`,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user