fix(webui): max rank (#859)

This commit is contained in:
Sainan 2025-01-24 15:44:34 +01:00 committed by GitHub
parent 5649c5bf86
commit 3cd66391b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 8 deletions

View File

@ -0,0 +1,20 @@
import { addGearExpByCategory, getInventory } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
import { RequestHandler } from "express";
export const addXpController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
const request = req.body as IAddXpRequest;
for (const [category, gear] of Object.entries(request)) {
addGearExpByCategory(inventory, gear, category as TEquipmentKey);
}
await inventory.save();
res.end();
};
type IAddXpRequest = {
[_ in TEquipmentKey]: IEquipmentClient[];
};

View File

@ -9,6 +9,7 @@ import { renameAccountController } from "@/src/controllers/custom/renameAccountC
import { createAccountController } from "@/src/controllers/custom/createAccountController";
import { addItemsController } from "@/src/controllers/custom/addItemsController";
import { addXpController } from "@/src/controllers/custom/addXpController";
import { importController } from "@/src/controllers/custom/importController";
import { getConfigDataController } from "@/src/controllers/custom/getConfigDataController";
@ -25,6 +26,7 @@ customRouter.get("/renameAccount", renameAccountController);
customRouter.post("/createAccount", createAccountController);
customRouter.post("/addItems", addItemsController);
customRouter.post("/addXp", addXpController);
customRouter.post("/import", importController);
customRouter.get("/config", getConfigDataController);

View File

@ -249,10 +249,7 @@ function updateInventory() {
maxXP /= 2;
}
if (
item.XP < maxXP &&
category != "MechSuits" // missionInventoryUpdate currently doesn't handle this category
) {
if (item.XP < maxXP) {
const a = document.createElement("a");
a.href = "#";
a.onclick = function (event) {
@ -645,8 +642,8 @@ function addGearExp(category, oid, xp) {
];
revalidateAuthz(() => {
$.post({
url: "/api/missionInventoryUpdate.php?" + window.authz,
contentType: "text/plain",
url: "/custom/addXp?" + window.authz,
contentType: "application/json",
data: JSON.stringify(data)
}).done(function () {
if (category != "SpecialItems") {
@ -659,8 +656,8 @@ function addGearExp(category, oid, xp) {
function sendBatchGearExp(data) {
revalidateAuthz(() => {
$.post({
url: "/api/missionInventoryUpdate.php?" + window.authz,
contentType: "text/plain",
url: "/custom/addXp?" + window.authz,
contentType: "application/json",
data: JSON.stringify(data)
}).done(() => {
updateInventory();