fix(webui): max rank

This commit is contained in:
Sainan 2025-01-24 15:35:29 +01:00
parent 5649c5bf86
commit 1d283722fb
3 changed files with 35 additions and 16 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();
@ -737,8 +734,8 @@ function doAcquireMiscItems() {
const [category, uniqueName] = data.split(":");
revalidateAuthz(() => {
$.post({
url: "/api/missionInventoryUpdate.php?" + window.authz,
contentType: "text/plain",
url: "/custom/addXp?" + window.authz,
contentType: "application/json",
data: JSON.stringify({
[category]: [
{
@ -774,8 +771,8 @@ function doAcquireRiven() {
revalidateAuthz(() => {
// Add riven type to inventory
$.post({
url: "/api/missionInventoryUpdate.php?" + window.authz,
contentType: "text/plain",
url: "/custom/addXp?" + window.authz,
contentType: "application/json",
data: JSON.stringify({
RawUpgrades: [
{
@ -848,8 +845,8 @@ function doAcquireMod() {
}
revalidateAuthz(() => {
$.post({
url: "/api/missionInventoryUpdate.php?" + window.authz,
contentType: "text/plain",
url: "/custom/addXp?" + window.authz,
contentType: "application/json",
data: JSON.stringify({
RawUpgrades: [
{
@ -1036,8 +1033,8 @@ function doAddAllMods() {
window.confirm("Are you sure you want to add " + modsAll.length + " mods to your account?")
) {
$.post({
url: "/api/missionInventoryUpdate.php?" + window.authz,
contentType: "text/plain",
url: "/custom/addXp?" + window.authz,
contentType: "application/json",
data: JSON.stringify({
RawUpgrades: modsAll.map(mod => ({
ItemType: mod,