Reviewed-on: #1400 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
22 lines
873 B
TypeScript
22 lines
873 B
TypeScript
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);
|
|
const inventory = await getInventory(accountId, req.query.Category as string);
|
|
const payload = getJSONfromString<ISetWeaponSkillTreeRequest>(String(req.body));
|
|
|
|
const item = inventory[req.query.Category as WeaponTypeInternal].id(req.query.ItemId as string)!;
|
|
item.SkillTree = payload.SkillTree;
|
|
|
|
await inventory.save();
|
|
res.end();
|
|
};
|
|
|
|
interface ISetWeaponSkillTreeRequest {
|
|
SkillTree: string;
|
|
}
|