2024-06-20 13:05:07 +02:00
|
|
|
import { RequestHandler } from "express";
|
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
|
|
|
import { getInventory } from "@/src/services/inventoryService";
|
|
|
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
|
|
|
import { WeaponTypeInternal } from "@/src/services/itemDataService";
|
|
|
|
|
|
|
|
export const setWeaponSkillTreeController: RequestHandler = async (req, res) => {
|
|
|
|
const accountId = await getAccountIdForRequest(req);
|
2025-03-31 04:15:32 -07:00
|
|
|
const inventory = await getInventory(accountId, req.query.Category as string);
|
2025-01-24 14:27:10 +01:00
|
|
|
const payload = getJSONfromString<ISetWeaponSkillTreeRequest>(String(req.body));
|
2024-06-20 13:05:07 +02:00
|
|
|
|
2025-03-31 04:15:32 -07:00
|
|
|
const item = inventory[req.query.Category as WeaponTypeInternal].id(req.query.ItemId as string)!;
|
2024-06-20 13:05:07 +02:00
|
|
|
item.SkillTree = payload.SkillTree;
|
|
|
|
|
|
|
|
await inventory.save();
|
|
|
|
res.end();
|
|
|
|
};
|
|
|
|
|
|
|
|
interface ISetWeaponSkillTreeRequest {
|
|
|
|
SkillTree: string;
|
|
|
|
}
|