feat: articula customizations (#2636)
Reviewed-on: #2636 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
parent
df316e3a7a
commit
62881aaa36
@ -1,23 +1,19 @@
|
|||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { IPictureFrameInfo, ISetPlacedDecoInfoRequest } from "@/src/types/personalRoomsTypes";
|
import { ISetPlacedDecoInfoRequest } from "@/src/types/personalRoomsTypes";
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { handleSetPlacedDecoInfo } from "@/src/services/shipCustomizationsService";
|
import { handleSetPlacedDecoInfo } from "@/src/services/shipCustomizationsService";
|
||||||
|
|
||||||
export const setPlacedDecoInfoController: RequestHandler = async (req, res) => {
|
export const setPlacedDecoInfoController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
const payload = JSON.parse(req.body as string) as ISetPlacedDecoInfoRequest;
|
const payload = JSON.parse(req.body as string) as ISetPlacedDecoInfoRequest;
|
||||||
|
//console.log(JSON.stringify(payload, null, 2));
|
||||||
await handleSetPlacedDecoInfo(accountId, payload);
|
await handleSetPlacedDecoInfo(accountId, payload);
|
||||||
res.json({
|
res.json({
|
||||||
DecoId: payload.DecoId,
|
...payload,
|
||||||
IsPicture: true,
|
IsPicture: !!payload.PictureFrameInfo
|
||||||
PictureFrameInfo: payload.PictureFrameInfo,
|
|
||||||
BootLocation: payload.BootLocation
|
|
||||||
} satisfies ISetPlacedDecoInfoResponse);
|
} satisfies ISetPlacedDecoInfoResponse);
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ISetPlacedDecoInfoResponse {
|
interface ISetPlacedDecoInfoResponse extends ISetPlacedDecoInfoRequest {
|
||||||
DecoId: string;
|
|
||||||
IsPicture: boolean;
|
IsPicture: boolean;
|
||||||
PictureFrameInfo?: IPictureFrameInfo;
|
|
||||||
BootLocation?: string;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ export const EquipmentSelectionSchema = new Schema<IEquipmentSelection>(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const loadoutConfigSchema = new Schema<ILoadoutConfigDatabase>(
|
export const loadoutConfigSchema = new Schema<ILoadoutConfigDatabase>(
|
||||||
{
|
{
|
||||||
FocusSchool: String,
|
FocusSchool: String,
|
||||||
PresetIcon: String,
|
PresetIcon: String,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
|
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
|
||||||
import {
|
import {
|
||||||
IApartmentDatabase,
|
IApartmentDatabase,
|
||||||
|
ICustomizationInfoDatabase,
|
||||||
IFavouriteLoadoutDatabase,
|
IFavouriteLoadoutDatabase,
|
||||||
IGardeningDatabase,
|
IGardeningDatabase,
|
||||||
IOrbiterClient,
|
IOrbiterClient,
|
||||||
@ -11,12 +12,13 @@ import {
|
|||||||
IPlantClient,
|
IPlantClient,
|
||||||
IPlantDatabase,
|
IPlantDatabase,
|
||||||
IPlanterDatabase,
|
IPlanterDatabase,
|
||||||
IRoom,
|
IRoomDatabase,
|
||||||
ITailorShopDatabase,
|
ITailorShopDatabase,
|
||||||
PersonalRoomsModelType
|
PersonalRoomsModelType
|
||||||
} from "@/src/types/personalRoomsTypes";
|
} from "@/src/types/personalRoomsTypes";
|
||||||
import { Schema, Types, model } from "mongoose";
|
import { Schema, Types, model } from "mongoose";
|
||||||
import { colorSchema, shipCustomizationSchema } from "@/src/models/commonModel";
|
import { colorSchema, shipCustomizationSchema } from "@/src/models/commonModel";
|
||||||
|
import { loadoutConfigSchema } from "@/src/models/inventoryModels/loadoutModel";
|
||||||
|
|
||||||
export const pictureFrameInfoSchema = new Schema<IPictureFrameInfo>(
|
export const pictureFrameInfoSchema = new Schema<IPictureFrameInfo>(
|
||||||
{
|
{
|
||||||
@ -34,7 +36,20 @@ export const pictureFrameInfoSchema = new Schema<IPictureFrameInfo>(
|
|||||||
TextColorB: Number,
|
TextColorB: Number,
|
||||||
TextOrientation: Number
|
TextOrientation: Number
|
||||||
},
|
},
|
||||||
{ id: false, _id: false }
|
{ _id: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
export const customizationInfoSchema = new Schema<ICustomizationInfoDatabase>(
|
||||||
|
{
|
||||||
|
Anim: String,
|
||||||
|
AnimPose: Number,
|
||||||
|
LoadOutPreset: loadoutConfigSchema,
|
||||||
|
VehiclePreset: loadoutConfigSchema,
|
||||||
|
EquippedWeapon: String,
|
||||||
|
AvatarType: String,
|
||||||
|
LoadOutType: String
|
||||||
|
},
|
||||||
|
{ _id: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
const placedDecosSchema = new Schema<IPlacedDecosDatabase>(
|
const placedDecosSchema = new Schema<IPlacedDecosDatabase>(
|
||||||
@ -44,7 +59,9 @@ const placedDecosSchema = new Schema<IPlacedDecosDatabase>(
|
|||||||
Rot: [Number],
|
Rot: [Number],
|
||||||
Scale: Number,
|
Scale: Number,
|
||||||
Sockets: Number,
|
Sockets: Number,
|
||||||
PictureFrameInfo: { type: pictureFrameInfoSchema, default: undefined }
|
PictureFrameInfo: { type: pictureFrameInfoSchema, default: undefined },
|
||||||
|
CustomizationInfo: { type: customizationInfoSchema, default: undefined },
|
||||||
|
AnimPoseItem: String
|
||||||
},
|
},
|
||||||
{ id: false }
|
{ id: false }
|
||||||
);
|
);
|
||||||
@ -60,7 +77,7 @@ placedDecosSchema.set("toJSON", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const roomSchema = new Schema<IRoom>(
|
const roomSchema = new Schema<IRoomDatabase>(
|
||||||
{
|
{
|
||||||
Name: String,
|
Name: String,
|
||||||
MaxCapacity: Number,
|
MaxCapacity: Number,
|
||||||
|
|||||||
@ -47,16 +47,22 @@ import {
|
|||||||
import {
|
import {
|
||||||
IApartmentClient,
|
IApartmentClient,
|
||||||
IApartmentDatabase,
|
IApartmentDatabase,
|
||||||
|
ICustomizationInfoClient,
|
||||||
|
ICustomizationInfoDatabase,
|
||||||
IFavouriteLoadout,
|
IFavouriteLoadout,
|
||||||
IFavouriteLoadoutDatabase,
|
IFavouriteLoadoutDatabase,
|
||||||
IGetShipResponse,
|
IGetShipResponse,
|
||||||
IOrbiterClient,
|
IOrbiterClient,
|
||||||
IOrbiterDatabase,
|
IOrbiterDatabase,
|
||||||
IPersonalRoomsDatabase,
|
IPersonalRoomsDatabase,
|
||||||
|
IPlacedDecosClient,
|
||||||
|
IPlacedDecosDatabase,
|
||||||
IPlantClient,
|
IPlantClient,
|
||||||
IPlantDatabase,
|
IPlantDatabase,
|
||||||
IPlanterClient,
|
IPlanterClient,
|
||||||
IPlanterDatabase,
|
IPlanterDatabase,
|
||||||
|
IRoomClient,
|
||||||
|
IRoomDatabase,
|
||||||
ITailorShop,
|
ITailorShop,
|
||||||
ITailorShopDatabase
|
ITailorShopDatabase
|
||||||
} from "@/src/types/personalRoomsTypes";
|
} from "@/src/types/personalRoomsTypes";
|
||||||
@ -446,6 +452,30 @@ export const importLoadOutPresets = (db: ILoadoutDatabase, client: ILoadOutPrese
|
|||||||
db.DRIFTER = client.DRIFTER.map(convertLoadOutConfig);
|
db.DRIFTER = client.DRIFTER.map(convertLoadOutConfig);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const convertCustomizationInfo = (client: ICustomizationInfoClient): ICustomizationInfoDatabase => {
|
||||||
|
return {
|
||||||
|
...client,
|
||||||
|
LoadOutPreset: client.LoadOutPreset ? convertLoadOutConfig(client.LoadOutPreset) : undefined,
|
||||||
|
VehiclePreset: client.VehiclePreset ? convertLoadOutConfig(client.VehiclePreset) : undefined
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const convertDeco = (client: IPlacedDecosClient): IPlacedDecosDatabase => {
|
||||||
|
const { id, ...rest } = client;
|
||||||
|
return {
|
||||||
|
...rest,
|
||||||
|
CustomizationInfo: client.CustomizationInfo ? convertCustomizationInfo(client.CustomizationInfo) : undefined,
|
||||||
|
_id: new Types.ObjectId(id.$oid)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const convertRoom = (client: IRoomClient): IRoomDatabase => {
|
||||||
|
return {
|
||||||
|
...client,
|
||||||
|
PlacedDecos: client.PlacedDecos ? client.PlacedDecos.map(convertDeco) : []
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const convertShip = (client: IOrbiterClient): IOrbiterDatabase => {
|
const convertShip = (client: IOrbiterClient): IOrbiterDatabase => {
|
||||||
return {
|
return {
|
||||||
...client,
|
...client,
|
||||||
@ -453,6 +483,7 @@ const convertShip = (client: IOrbiterClient): IOrbiterDatabase => {
|
|||||||
...client.ShipInterior,
|
...client.ShipInterior,
|
||||||
Colors: Array.isArray(client.ShipInterior.Colors) ? {} : client.ShipInterior.Colors
|
Colors: Array.isArray(client.ShipInterior.Colors) ? {} : client.ShipInterior.Colors
|
||||||
},
|
},
|
||||||
|
Rooms: client.Rooms.map(convertRoom),
|
||||||
FavouriteLoadoutId: client.FavouriteLoadoutId ? new Types.ObjectId(client.FavouriteLoadoutId.$oid) : undefined
|
FavouriteLoadoutId: client.FavouriteLoadoutId ? new Types.ObjectId(client.FavouriteLoadoutId.$oid) : undefined
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -481,6 +512,7 @@ const convertFavouriteLoadout = (client: IFavouriteLoadout): IFavouriteLoadoutDa
|
|||||||
const convertApartment = (client: IApartmentClient): IApartmentDatabase => {
|
const convertApartment = (client: IApartmentClient): IApartmentDatabase => {
|
||||||
return {
|
return {
|
||||||
...client,
|
...client,
|
||||||
|
Rooms: client.Rooms.map(convertRoom),
|
||||||
Gardening: { Planters: client.Gardening.Planters.map(convertPlanter) },
|
Gardening: { Planters: client.Gardening.Planters.map(convertPlanter) },
|
||||||
FavouriteLoadouts: client.FavouriteLoadouts ? client.FavouriteLoadouts.map(convertFavouriteLoadout) : []
|
FavouriteLoadouts: client.FavouriteLoadouts ? client.FavouriteLoadouts.map(convertFavouriteLoadout) : []
|
||||||
};
|
};
|
||||||
@ -489,6 +521,7 @@ const convertApartment = (client: IApartmentClient): IApartmentDatabase => {
|
|||||||
const convertTailorShop = (client: ITailorShop): ITailorShopDatabase => {
|
const convertTailorShop = (client: ITailorShop): ITailorShopDatabase => {
|
||||||
return {
|
return {
|
||||||
...client,
|
...client,
|
||||||
|
Rooms: client.Rooms.map(convertRoom),
|
||||||
Colors: Array.isArray(client.Colors) ? {} : client.Colors,
|
Colors: Array.isArray(client.Colors) ? {} : client.Colors,
|
||||||
FavouriteLoadouts: client.FavouriteLoadouts ? client.FavouriteLoadouts.map(convertFavouriteLoadout) : []
|
FavouriteLoadouts: client.FavouriteLoadouts ? client.FavouriteLoadouts.map(convertFavouriteLoadout) : []
|
||||||
};
|
};
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import { Guild } from "@/src/models/guildModel";
|
|||||||
import { hasGuildPermission } from "@/src/services/guildService";
|
import { hasGuildPermission } from "@/src/services/guildService";
|
||||||
import { GuildPermission } from "@/src/types/guildTypes";
|
import { GuildPermission } from "@/src/types/guildTypes";
|
||||||
import { ExportResources } from "warframe-public-export-plus";
|
import { ExportResources } from "warframe-public-export-plus";
|
||||||
|
import { convertCustomizationInfo } from "@/src/services/importService";
|
||||||
|
|
||||||
export const setShipCustomizations = async (
|
export const setShipCustomizations = async (
|
||||||
accountId: string,
|
accountId: string,
|
||||||
@ -269,6 +270,8 @@ export const handleSetPlacedDecoInfo = async (accountId: string, req: ISetPlaced
|
|||||||
}
|
}
|
||||||
|
|
||||||
placedDeco.PictureFrameInfo = req.PictureFrameInfo;
|
placedDeco.PictureFrameInfo = req.PictureFrameInfo;
|
||||||
|
placedDeco.CustomizationInfo = req.CustomizationInfo ? convertCustomizationInfo(req.CustomizationInfo) : undefined;
|
||||||
|
placedDeco.AnimPoseItem = req.AnimPoseItem;
|
||||||
|
|
||||||
await personalRooms.save();
|
await personalRooms.save();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { IColor, IShipAttachments, IShipCustomization } from "@/src/types/inventoryTypes/commonInventoryTypes";
|
import { IColor, IShipAttachments, IShipCustomization } from "@/src/types/inventoryTypes/commonInventoryTypes";
|
||||||
import { Document, Model, Types } from "mongoose";
|
import { Document, Model, Types } from "mongoose";
|
||||||
import { ILoadoutClient } from "@/src/types/saveLoadoutTypes";
|
import { ILoadoutClient, ILoadoutConfigClient, ILoadoutConfigDatabase } from "@/src/types/saveLoadoutTypes";
|
||||||
import { IMongoDate, IOid } from "@/src/types/commonTypes";
|
import { IMongoDate, IOid } from "@/src/types/commonTypes";
|
||||||
|
|
||||||
export interface IGetShipResponse {
|
export interface IGetShipResponse {
|
||||||
@ -17,7 +17,7 @@ export interface IOrbiterClient {
|
|||||||
Features: string[];
|
Features: string[];
|
||||||
ShipId: IOid;
|
ShipId: IOid;
|
||||||
ShipInterior: IShipCustomization;
|
ShipInterior: IShipCustomization;
|
||||||
Rooms: IRoom[];
|
Rooms: IRoomClient[];
|
||||||
VignetteFish?: string[];
|
VignetteFish?: string[];
|
||||||
FavouriteLoadoutId?: IOid;
|
FavouriteLoadoutId?: IOid;
|
||||||
Wallpaper?: string;
|
Wallpaper?: string;
|
||||||
@ -28,7 +28,7 @@ export interface IOrbiterClient {
|
|||||||
|
|
||||||
export interface IOrbiterDatabase {
|
export interface IOrbiterDatabase {
|
||||||
Features: string[];
|
Features: string[];
|
||||||
Rooms: IRoom[];
|
Rooms: IRoomDatabase[];
|
||||||
ShipInterior?: IShipCustomization;
|
ShipInterior?: IShipCustomization;
|
||||||
VignetteFish?: string[];
|
VignetteFish?: string[];
|
||||||
FavouriteLoadoutId?: Types.ObjectId;
|
FavouriteLoadoutId?: Types.ObjectId;
|
||||||
@ -53,12 +53,18 @@ export interface IPersonalRoomsDatabase {
|
|||||||
TailorShop: ITailorShopDatabase;
|
TailorShop: ITailorShopDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IRoom {
|
export interface IRoomDatabase {
|
||||||
Name: string;
|
Name: string;
|
||||||
MaxCapacity: number;
|
MaxCapacity: number;
|
||||||
PlacedDecos?: IPlacedDecosDatabase[];
|
PlacedDecos?: IPlacedDecosDatabase[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IRoomClient {
|
||||||
|
Name: string;
|
||||||
|
MaxCapacity: number;
|
||||||
|
PlacedDecos?: IPlacedDecosClient[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface IPlantClient {
|
export interface IPlantClient {
|
||||||
PlantType: string;
|
PlantType: string;
|
||||||
EndTime: IMongoDate;
|
EndTime: IMongoDate;
|
||||||
@ -89,7 +95,7 @@ export interface IGardeningDatabase {
|
|||||||
|
|
||||||
export interface IApartmentClient {
|
export interface IApartmentClient {
|
||||||
Gardening: IGardeningClient;
|
Gardening: IGardeningClient;
|
||||||
Rooms: IRoom[];
|
Rooms: IRoomClient[];
|
||||||
FavouriteLoadouts?: IFavouriteLoadout[];
|
FavouriteLoadouts?: IFavouriteLoadout[];
|
||||||
VideoWallBackdrop?: string;
|
VideoWallBackdrop?: string;
|
||||||
Soundscape?: string;
|
Soundscape?: string;
|
||||||
@ -97,7 +103,7 @@ export interface IApartmentClient {
|
|||||||
|
|
||||||
export interface IApartmentDatabase {
|
export interface IApartmentDatabase {
|
||||||
Gardening: IGardeningDatabase;
|
Gardening: IGardeningDatabase;
|
||||||
Rooms: IRoom[];
|
Rooms: IRoomDatabase[];
|
||||||
FavouriteLoadouts: IFavouriteLoadoutDatabase[];
|
FavouriteLoadouts: IFavouriteLoadoutDatabase[];
|
||||||
VideoWallBackdrop?: string;
|
VideoWallBackdrop?: string;
|
||||||
Soundscape?: string;
|
Soundscape?: string;
|
||||||
@ -110,11 +116,14 @@ export interface IPlacedDecosDatabase {
|
|||||||
Scale?: number;
|
Scale?: number;
|
||||||
Sockets?: number;
|
Sockets?: number;
|
||||||
PictureFrameInfo?: IPictureFrameInfo;
|
PictureFrameInfo?: IPictureFrameInfo;
|
||||||
|
CustomizationInfo?: ICustomizationInfoDatabase;
|
||||||
|
AnimPoseItem?: string;
|
||||||
_id: Types.ObjectId;
|
_id: Types.ObjectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPlacedDecosClient extends Omit<IPlacedDecosDatabase, "_id"> {
|
export interface IPlacedDecosClient extends Omit<IPlacedDecosDatabase, "_id" | "CustomizationInfo"> {
|
||||||
id: IOid;
|
id: IOid;
|
||||||
|
CustomizationInfo?: ICustomizationInfoClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISetShipCustomizationsRequest {
|
export interface ISetShipCustomizationsRequest {
|
||||||
@ -166,11 +175,13 @@ export interface IResetShipDecorationsResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ISetPlacedDecoInfoRequest {
|
export interface ISetPlacedDecoInfoRequest {
|
||||||
DecoType: string;
|
DecoType?: string;
|
||||||
DecoId: string;
|
DecoId: string;
|
||||||
Room: string;
|
Room: string;
|
||||||
PictureFrameInfo: IPictureFrameInfo;
|
PictureFrameInfo: IPictureFrameInfo; // IsPicture
|
||||||
|
CustomizationInfo?: ICustomizationInfoClient; // !IsPicture
|
||||||
BootLocation?: TBootLocation;
|
BootLocation?: TBootLocation;
|
||||||
|
AnimPoseItem?: string; // !IsPicture
|
||||||
ComponentId?: string;
|
ComponentId?: string;
|
||||||
GuildId?: string;
|
GuildId?: string;
|
||||||
}
|
}
|
||||||
@ -191,6 +202,21 @@ export interface IPictureFrameInfo {
|
|||||||
TextOrientation: number;
|
TextOrientation: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ICustomizationInfoClient {
|
||||||
|
Anim?: string;
|
||||||
|
AnimPose?: number;
|
||||||
|
LoadOutPreset?: ILoadoutConfigClient;
|
||||||
|
VehiclePreset?: ILoadoutConfigClient;
|
||||||
|
EquippedWeapon?: "SUIT_SLOT" | "LONG_GUN_SLOT" | "PISTOL_SLOT";
|
||||||
|
AvatarType?: string;
|
||||||
|
LoadOutType?: string; // "LOT_NORMAL"
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ICustomizationInfoDatabase extends Omit<ICustomizationInfoClient, "LoadOutPreset" | "VehiclePreset"> {
|
||||||
|
LoadOutPreset?: ILoadoutConfigDatabase;
|
||||||
|
VehiclePreset?: ILoadoutConfigDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IFavouriteLoadout {
|
export interface IFavouriteLoadout {
|
||||||
Tag: string;
|
Tag: string;
|
||||||
LoadoutId: IOid;
|
LoadoutId: IOid;
|
||||||
@ -206,10 +232,11 @@ export interface ITailorShopDatabase {
|
|||||||
Colors?: IColor;
|
Colors?: IColor;
|
||||||
CustomJson?: string;
|
CustomJson?: string;
|
||||||
LevelDecosVisible?: boolean;
|
LevelDecosVisible?: boolean;
|
||||||
Rooms: IRoom[];
|
Rooms: IRoomDatabase[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITailorShop extends Omit<ITailorShopDatabase, "FavouriteLoadouts"> {
|
export interface ITailorShop extends Omit<ITailorShopDatabase, "Rooms" | "FavouriteLoadouts"> {
|
||||||
|
Rooms: IRoomClient[];
|
||||||
FavouriteLoadouts?: IFavouriteLoadout[];
|
FavouriteLoadouts?: IFavouriteLoadout[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user