XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
UTF-8
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
import { getInventory2 } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import type { IIncentiveState } from "../../types/inventoryTypes/inventoryTypes.ts";
import type { RequestHandler } from "express";

export const startCollectibleEntryController: RequestHandler = async (req, res) => {
    const accountId = await getAccountIdForRequest(req);
    const inventory = await getInventory2(accountId, "CollectibleSeries");
    const request = getJSONfromString<IStartCollectibleEntryRequest>(String(req.body));
    inventory.CollectibleSeries ??= [];
    inventory.CollectibleSeries.push({
        CollectibleType: request.target,
        Count: 0,
        Tracking: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
        ReqScans: request.reqScans,
        IncentiveStates: request.other
    });
    await inventory.save();
    res.send(`target = ${request.target}key = 0key = 1{"Target":"${request.target}"}`);
};

interface IStartCollectibleEntryRequest {
    target: string;
    reqScans: number;
    other: IIncentiveState[];
}