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 type { RequestHandler } from "express";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { getPersonalRooms } from "../../services/personalRoomsService.ts";
import type { TBootLocation } from "../../types/personalRoomsTypes.ts";
import { getInventory2 } from "../../services/inventoryService.ts";

export const setBootLocationController: RequestHandler = async (req, res) => {
    const accountId = await getAccountIdForRequest(req);
    const personalRooms = await getPersonalRooms(accountId, "Ship");
    personalRooms.Ship.BootLocation = req.query.bootLocation as string as TBootLocation;
    await personalRooms.save();

    if (personalRooms.Ship.BootLocation == "SHOP") {
        // Temp fix so the motorcycle in the backroom doesn't appear broken.
        // This code may be removed when quests are fully implemented.
        const inventory = await getInventory2(accountId, "Motorcycles");
        if (inventory.Motorcycles.length == 0) {
            inventory.Motorcycles.push({ ItemType: "/Lotus/Types/Vehicles/Motorcycle/MotorcyclePowerSuit" });
            await inventory.save();
        }
    }

    res.end();
};