feat: change loadout display in liset

This commit is contained in:
Sainan 2025-04-14 04:22:04 +02:00
parent 7736a2bf65
commit 6fa23fe95b
5 changed files with 30 additions and 14 deletions

View File

@ -26,7 +26,10 @@ export const getShipController: RequestHandler = async (req, res) => {
Colors: personalRooms.ShipInteriorColors, Colors: personalRooms.ShipInteriorColors,
ShipAttachments: ship.ShipAttachments, ShipAttachments: ship.ShipAttachments,
SkinFlavourItem: ship.SkinFlavourItem SkinFlavourItem: ship.SkinFlavourItem
} },
FavouriteLoadoutId: personalRooms.Ship.FavouriteLoadoutId
? toOid(personalRooms.Ship.FavouriteLoadoutId)
: undefined
}, },
Apartment: personalRooms.Apartment, Apartment: personalRooms.Apartment,
TailorShop: personalRooms.TailorShop TailorShop: personalRooms.TailorShop

View File

@ -3,29 +3,33 @@ import { RequestHandler } from "express";
import { getPersonalRooms } from "@/src/services/personalRoomsService"; import { getPersonalRooms } from "@/src/services/personalRoomsService";
import { IOid } from "@/src/types/commonTypes"; import { IOid } from "@/src/types/commonTypes";
import { Types } from "mongoose"; import { Types } from "mongoose";
import { TBootLocation } from "@/src/types/shipTypes";
export const setShipFavouriteLoadoutController: RequestHandler = async (req, res) => { export const setShipFavouriteLoadoutController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req); const accountId = await getAccountIdForRequest(req);
const personalRooms = await getPersonalRooms(accountId); const personalRooms = await getPersonalRooms(accountId);
const body = JSON.parse(String(req.body)) as ISetShipFavouriteLoadoutRequest; const body = JSON.parse(String(req.body)) as ISetShipFavouriteLoadoutRequest;
if (body.BootLocation != "SHOP") { if (body.BootLocation == "LISET") {
throw new Error(`unexpected BootLocation: ${body.BootLocation}`); personalRooms.Ship.FavouriteLoadoutId = new Types.ObjectId(body.FavouriteLoadoutId.$oid);
} } else if (body.BootLocation == "SHOP") {
const display = personalRooms.TailorShop.FavouriteLoadouts.find(x => x.Tag == body.TagName); const display = personalRooms.TailorShop.FavouriteLoadouts.find(x => x.Tag == body.TagName!);
if (display) { if (display) {
display.LoadoutId = new Types.ObjectId(body.FavouriteLoadoutId.$oid); display.LoadoutId = new Types.ObjectId(body.FavouriteLoadoutId.$oid);
} else { } else {
personalRooms.TailorShop.FavouriteLoadouts.push({ personalRooms.TailorShop.FavouriteLoadouts.push({
Tag: body.TagName, Tag: body.TagName!,
LoadoutId: new Types.ObjectId(body.FavouriteLoadoutId.$oid) LoadoutId: new Types.ObjectId(body.FavouriteLoadoutId.$oid)
}); });
} }
} else {
throw new Error(`unexpected BootLocation: ${body.BootLocation}`);
}
await personalRooms.save(); await personalRooms.save();
res.json({}); res.json({});
}; };
interface ISetShipFavouriteLoadoutRequest { interface ISetShipFavouriteLoadoutRequest {
BootLocation: string; BootLocation: TBootLocation;
FavouriteLoadoutId: IOid; FavouriteLoadoutId: IOid;
TagName: string; TagName?: string; // given request for SHOP, but not for LISET
} }

View File

@ -90,6 +90,9 @@ const orbiterSchema = new Schema<IOrbiter>(
{ {
Features: [String], Features: [String],
Rooms: [roomSchema], Rooms: [roomSchema],
VignetteFish: { type: [String], default: undefined },
FavouriteLoadoutId: Schema.Types.ObjectId,
Vignette: String,
ContentUrlSignature: { type: String, required: false }, ContentUrlSignature: { type: String, required: false },
BootLocation: String BootLocation: String
}, },

View File

@ -12,6 +12,9 @@ import { Document, Model, Types } from "mongoose";
export interface IOrbiter { export interface IOrbiter {
Features: string[]; Features: string[];
Rooms: IRoom[]; Rooms: IRoom[];
VignetteFish?: string[];
FavouriteLoadoutId?: Types.ObjectId;
Vignette?: string;
ContentUrlSignature?: string; ContentUrlSignature?: string;
BootLocation?: TBootLocation; BootLocation?: TBootLocation;
} }

View File

@ -28,8 +28,11 @@ export interface IShip {
ShipId: IOid; ShipId: IOid;
ShipInterior: IShipInterior; ShipInterior: IShipInterior;
Rooms: IRoom[]; Rooms: IRoom[];
ContentUrlSignature?: string; VignetteFish?: string[];
FavouriteLoadoutId?: IOid;
Vignette?: string;
BootLocation?: TBootLocation; BootLocation?: TBootLocation;
ContentUrlSignature?: string;
} }
export interface IShipDatabase { export interface IShipDatabase {