feat: change loadout display in liset
This commit is contained in:
parent
7736a2bf65
commit
6fa23fe95b
@ -26,7 +26,10 @@ export const getShipController: RequestHandler = async (req, res) => {
|
||||
Colors: personalRooms.ShipInteriorColors,
|
||||
ShipAttachments: ship.ShipAttachments,
|
||||
SkinFlavourItem: ship.SkinFlavourItem
|
||||
}
|
||||
},
|
||||
FavouriteLoadoutId: personalRooms.Ship.FavouriteLoadoutId
|
||||
? toOid(personalRooms.Ship.FavouriteLoadoutId)
|
||||
: undefined
|
||||
},
|
||||
Apartment: personalRooms.Apartment,
|
||||
TailorShop: personalRooms.TailorShop
|
||||
|
@ -3,29 +3,33 @@ import { RequestHandler } from "express";
|
||||
import { getPersonalRooms } from "@/src/services/personalRoomsService";
|
||||
import { IOid } from "@/src/types/commonTypes";
|
||||
import { Types } from "mongoose";
|
||||
import { TBootLocation } from "@/src/types/shipTypes";
|
||||
|
||||
export const setShipFavouriteLoadoutController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
const personalRooms = await getPersonalRooms(accountId);
|
||||
const body = JSON.parse(String(req.body)) as ISetShipFavouriteLoadoutRequest;
|
||||
if (body.BootLocation != "SHOP") {
|
||||
throw new Error(`unexpected BootLocation: ${body.BootLocation}`);
|
||||
}
|
||||
const display = personalRooms.TailorShop.FavouriteLoadouts.find(x => x.Tag == body.TagName);
|
||||
if (body.BootLocation == "LISET") {
|
||||
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!);
|
||||
if (display) {
|
||||
display.LoadoutId = new Types.ObjectId(body.FavouriteLoadoutId.$oid);
|
||||
} else {
|
||||
personalRooms.TailorShop.FavouriteLoadouts.push({
|
||||
Tag: body.TagName,
|
||||
Tag: body.TagName!,
|
||||
LoadoutId: new Types.ObjectId(body.FavouriteLoadoutId.$oid)
|
||||
});
|
||||
}
|
||||
} else {
|
||||
throw new Error(`unexpected BootLocation: ${body.BootLocation}`);
|
||||
}
|
||||
await personalRooms.save();
|
||||
res.json({});
|
||||
};
|
||||
|
||||
interface ISetShipFavouriteLoadoutRequest {
|
||||
BootLocation: string;
|
||||
BootLocation: TBootLocation;
|
||||
FavouriteLoadoutId: IOid;
|
||||
TagName: string;
|
||||
TagName?: string; // given request for SHOP, but not for LISET
|
||||
}
|
||||
|
@ -90,6 +90,9 @@ const orbiterSchema = new Schema<IOrbiter>(
|
||||
{
|
||||
Features: [String],
|
||||
Rooms: [roomSchema],
|
||||
VignetteFish: { type: [String], default: undefined },
|
||||
FavouriteLoadoutId: Schema.Types.ObjectId,
|
||||
Vignette: String,
|
||||
ContentUrlSignature: { type: String, required: false },
|
||||
BootLocation: String
|
||||
},
|
||||
|
@ -12,6 +12,9 @@ import { Document, Model, Types } from "mongoose";
|
||||
export interface IOrbiter {
|
||||
Features: string[];
|
||||
Rooms: IRoom[];
|
||||
VignetteFish?: string[];
|
||||
FavouriteLoadoutId?: Types.ObjectId;
|
||||
Vignette?: string;
|
||||
ContentUrlSignature?: string;
|
||||
BootLocation?: TBootLocation;
|
||||
}
|
||||
|
@ -28,8 +28,11 @@ export interface IShip {
|
||||
ShipId: IOid;
|
||||
ShipInterior: IShipInterior;
|
||||
Rooms: IRoom[];
|
||||
ContentUrlSignature?: string;
|
||||
VignetteFish?: string[];
|
||||
FavouriteLoadoutId?: IOid;
|
||||
Vignette?: string;
|
||||
BootLocation?: TBootLocation;
|
||||
ContentUrlSignature?: string;
|
||||
}
|
||||
|
||||
export interface IShipDatabase {
|
||||
|
Loading…
x
Reference in New Issue
Block a user