返回提交历史
Added
src/controllers/api/setPlacedDecoInfoController.ts
+12
-0
Modified
src/models/personalRoomsModel.ts
+22
-2
Modified
src/routes/api.ts
+2
-0
Modified
src/services/shipCustomizationsService.ts
+22
-1
Modified
src/types/shipTypes.ts
+25
-0
XFEstudio/XFESpaceNinjaServer
feat: implement setPlacedDecoInfo (#558)
ba349535
代码差异
5 个文件
+83
-3
@@ -0,0 +1,12 @@
1
import { getAccountIdForRequest } from "@/src/services/loginService";
2
import { ISetPlacedDecoInfoRequest } from "@/src/types/shipTypes";
3
import { RequestHandler } from "express";
4
import { handleSetPlacedDecoInfo } from "@/src/services/shipCustomizationsService";
5
6
// eslint-disable-next-line @typescript-eslint/no-misused-promises
7
export const setPlacedDecoInfoController: RequestHandler = async (req, res) => {
8
const accountId = await getAccountIdForRequest(req);
9
const payload = JSON.parse(req.body as string) as ISetPlacedDecoInfoRequest;
10
await handleSetPlacedDecoInfo(accountId, payload);
11
res.end();
12
};
@@ -1,14 +1,34 @@
1
1
import { toOid } from "@/src/helpers/inventoryHelpers";
2
2
import { IOrbiter, IPersonalRooms, PersonalRoomsModelType } from "@/src/types/personalRoomsTypes";
3
import { IApartment, IGardening, IPlacedDecosDatabase } from "@/src/types/shipTypes";
3
import { IApartment, IGardening, IPlacedDecosDatabase, IPictureFrameInfo } from "@/src/types/shipTypes";
4
4
import { Schema, model } from "mongoose";
5
5
6
const pictureFrameInfoSchema = new Schema<IPictureFrameInfo>(
7
{
8
Image: String,
9
Filter: String,
10
XOffset: Number,
11
YOffset: Number,
12
Scale: Number,
13
InvertX: Boolean,
14
InvertY: Boolean,
15
ColorCorrection: Number,
16
Text: String,
17
TextScale: Number,
18
TextColorA: Number,
19
TextColorB: Number,
20
TextOrientation: Number
21
},
22
{ id: false, _id: false }
23
);
24
6
25
const placedDecosSchema = new Schema<IPlacedDecosDatabase>(
7
26
{
8
27
Type: String,
9
28
Pos: [Number],
10
29
Rot: [Number],
11
Scale: Number
30
Scale: Number,
31
PictureFrameInfo: { type: pictureFrameInfoSchema, default: undefined }
12
32
},
13
33
{ id: false }
14
34
);
@@ -51,6 +51,7 @@ import { sellController } from "@/src/controllers/api/sellController";
51
51
import { setActiveQuestController } from "@/src/controllers/api/setActiveQuestController";
52
52
import { setActiveShipController } from "@/src/controllers/api/setActiveShipController";
53
53
import { setBootLocationController } from "@/src/controllers/api/setBootLocationController";
54
import { setPlacedDecoInfoController } from "@/src/controllers/api/setPlacedDecoInfoController";
54
55
import { setShipCustomizationsController } from "@/src/controllers/api/setShipCustomizationsController";
55
56
import { setSupportedSyndicateController } from "@/src/controllers/api/setSupportedSyndicateController";
56
57
import { setWeaponSkillTreeController } from "../controllers/api/setWeaponSkillTreeController";
@@ -128,6 +129,7 @@ apiRouter.post("/purchase.php", purchaseController);
128
129
apiRouter.post("/rerollRandomMod.php", rerollRandomModController);
129
130
apiRouter.post("/saveLoadout.php", saveLoadoutController);
130
131
apiRouter.post("/sell.php", sellController);
132
apiRouter.post("/setPlacedDecoInfo.php", setPlacedDecoInfoController);
131
133
apiRouter.post("/setShipCustomizations.php", setShipCustomizationsController);
132
134
apiRouter.post("/setWeaponSkillTree.php", setWeaponSkillTreeController);
133
135
apiRouter.post("/shipDecorations.php", shipDecorationsController);
@@ -4,7 +4,8 @@ import {
4
4
ISetShipCustomizationsRequest,
5
5
IShipDatabase,
6
6
IShipDecorationsRequest,
7
IShipDecorationsResponse
7
IShipDecorationsResponse,
8
ISetPlacedDecoInfoRequest
8
9
} from "@/src/types/shipTypes";
9
10
import { logger } from "@/src/utils/logger";
10
11
import { Types } from "mongoose";
@@ -131,3 +132,23 @@ export const handleSetShipDecorations = async (
131
132
132
133
return { DecoId: decoId.toString(), Room: placedDecoration.Room, IsApartment: placedDecoration.IsApartment };
133
134
};
135
136
export const handleSetPlacedDecoInfo = async (accountId: string, req: ISetPlacedDecoInfoRequest): Promise<void> => {
137
const personalRooms = await getPersonalRooms(accountId);
138
139
const room = personalRooms.Ship.Rooms.find(room => room.Name === req.Room);
140
if (!room) {
141
logger.error("room not found");
142
throw new Error("room not found");
143
}
144
145
const placedDeco = room.PlacedDecos?.find(x => x._id.toString() == req.DecoId);
146
if (!placedDeco) {
147
logger.error("deco not found");
148
throw new Error("deco not found");
149
}
150
151
placedDeco.PictureFrameInfo = req.PictureFrameInfo;
152
153
await personalRooms.save();
154
};
@@ -70,6 +70,7 @@ export interface IPlacedDecosDatabase {
70
70
Pos: [number, number, number];
71
71
Rot: [number, number, number];
72
72
Scale: number;
73
PictureFrameInfo?: IPictureFrameInfo;
73
74
_id: Types.ObjectId;
74
75
}
75
76
@@ -115,3 +116,27 @@ export interface IShipDecorationsResponse {
115
116
OldRoom?: string;
116
117
NewRoom?: string;
117
118
}
119
120
export interface ISetPlacedDecoInfoRequest {
121
DecoType: string;
122
DecoId: string;
123
Room: string;
124
PictureFrameInfo: IPictureFrameInfo;
125
BootLocation: string;
126
}
127
128
export interface IPictureFrameInfo {
129
Image: string;
130
Filter: string;
131
XOffset: number;
132
YOffset: number;
133
Scale: number;
134
InvertX: boolean;
135
InvertY: boolean;
136
ColorCorrection: number;
137
Text: string;
138
TextScale: number;
139
TextColorA: number;
140
TextColorB: number;
141
TextOrientation: number;
142
}