forked from OpenWF/SpaceNinjaServer
fix(webui): max rank (#859)
This commit is contained in:
parent
5649c5bf86
commit
3cd66391b6
20
src/controllers/custom/addXpController.ts
Normal file
20
src/controllers/custom/addXpController.ts
Normal 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[];
|
||||||
|
};
|
@ -9,6 +9,7 @@ import { renameAccountController } from "@/src/controllers/custom/renameAccountC
|
|||||||
|
|
||||||
import { createAccountController } from "@/src/controllers/custom/createAccountController";
|
import { createAccountController } from "@/src/controllers/custom/createAccountController";
|
||||||
import { addItemsController } from "@/src/controllers/custom/addItemsController";
|
import { addItemsController } from "@/src/controllers/custom/addItemsController";
|
||||||
|
import { addXpController } from "@/src/controllers/custom/addXpController";
|
||||||
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";
|
||||||
@ -25,6 +26,7 @@ customRouter.get("/renameAccount", renameAccountController);
|
|||||||
|
|
||||||
customRouter.post("/createAccount", createAccountController);
|
customRouter.post("/createAccount", createAccountController);
|
||||||
customRouter.post("/addItems", addItemsController);
|
customRouter.post("/addItems", addItemsController);
|
||||||
|
customRouter.post("/addXp", addXpController);
|
||||||
customRouter.post("/import", importController);
|
customRouter.post("/import", importController);
|
||||||
|
|
||||||
customRouter.get("/config", getConfigDataController);
|
customRouter.get("/config", getConfigDataController);
|
||||||
|
@ -249,10 +249,7 @@ function updateInventory() {
|
|||||||
maxXP /= 2;
|
maxXP /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (item.XP < maxXP) {
|
||||||
item.XP < maxXP &&
|
|
||||||
category != "MechSuits" // missionInventoryUpdate currently doesn't handle this category
|
|
||||||
) {
|
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
a.href = "#";
|
a.href = "#";
|
||||||
a.onclick = function (event) {
|
a.onclick = function (event) {
|
||||||
@ -645,8 +642,8 @@ function addGearExp(category, oid, xp) {
|
|||||||
];
|
];
|
||||||
revalidateAuthz(() => {
|
revalidateAuthz(() => {
|
||||||
$.post({
|
$.post({
|
||||||
url: "/api/missionInventoryUpdate.php?" + window.authz,
|
url: "/custom/addXp?" + window.authz,
|
||||||
contentType: "text/plain",
|
contentType: "application/json",
|
||||||
data: JSON.stringify(data)
|
data: JSON.stringify(data)
|
||||||
}).done(function () {
|
}).done(function () {
|
||||||
if (category != "SpecialItems") {
|
if (category != "SpecialItems") {
|
||||||
@ -659,8 +656,8 @@ function addGearExp(category, oid, xp) {
|
|||||||
function sendBatchGearExp(data) {
|
function sendBatchGearExp(data) {
|
||||||
revalidateAuthz(() => {
|
revalidateAuthz(() => {
|
||||||
$.post({
|
$.post({
|
||||||
url: "/api/missionInventoryUpdate.php?" + window.authz,
|
url: "/custom/addXp?" + window.authz,
|
||||||
contentType: "text/plain",
|
contentType: "application/json",
|
||||||
data: JSON.stringify(data)
|
data: JSON.stringify(data)
|
||||||
}).done(() => {
|
}).done(() => {
|
||||||
updateInventory();
|
updateInventory();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user