返回提交历史
Modified
src/services/shipCustomizationsService.ts
+19
-4
Modified
src/types/shipTypes.ts
+1
-1
XFEstudio/XFESpaceNinjaServer
fix: handle setPlacedDecoInfo for non-ship boot locations (#2349)
Closes #2347 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2349 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
69f9d5eb
代码差异
2 个文件
+20
-5
@@ -4,7 +4,8 @@ import {
4
4
ISetShipCustomizationsRequest,
5
5
IShipDecorationsRequest,
6
6
IShipDecorationsResponse,
7
ISetPlacedDecoInfoRequest
7
ISetPlacedDecoInfoRequest,
8
TBootLocation
8
9
} from "@/src/types/shipTypes";
9
10
import { logger } from "@/src/utils/logger";
10
11
import { Types } from "mongoose";
@@ -14,6 +15,7 @@ import { Guild } from "../models/guildModel";
14
15
import { hasGuildPermission } from "./guildService";
15
16
import { GuildPermission } from "../types/guildTypes";
16
17
import { ExportResources } from "warframe-public-export-plus";
18
import { RoomsType, TPersonalRoomsDatabaseDocument } from "../types/personalRoomsTypes";
17
19
18
20
export const setShipCustomizations = async (
19
21
accountId: string,
@@ -183,6 +185,19 @@ export const handleSetShipDecorations = async (
183
185
};
184
186
};
185
187
188
const getRoomsForBootLocation = (
189
personalRooms: TPersonalRoomsDatabaseDocument,
190
bootLocation: TBootLocation | undefined
191
): RoomsType[] => {
192
if (bootLocation == "SHOP") {
193
return personalRooms.TailorShop.Rooms;
194
}
195
if (bootLocation == "APARTMENT") {
196
return personalRooms.Apartment.Rooms;
197
}
198
return personalRooms.Ship.Rooms;
199
};
200
186
201
export const handleSetPlacedDecoInfo = async (accountId: string, req: ISetPlacedDecoInfoRequest): Promise<void> => {
187
202
if (req.GuildId && req.ComponentId) {
188
203
const guild = (await Guild.findById(req.GuildId))!;
@@ -197,14 +212,14 @@ export const handleSetPlacedDecoInfo = async (accountId: string, req: ISetPlaced
197
212
198
213
const personalRooms = await getPersonalRooms(accountId);
199
214
200
const room = personalRooms.Ship.Rooms.find(room => room.Name === req.Room);
215
const room = getRoomsForBootLocation(personalRooms, req.BootLocation).find(room => room.Name === req.Room);
201
216
if (!room) {
202
throw new Error("room not found");
217
throw new Error(`unknown room: ${req.Room}`);
203
218
}
204
219
205
220
const placedDeco = room.PlacedDecos.id(req.DecoId);
206
221
if (!placedDeco) {
207
throw new Error("deco not found");
222
throw new Error(`unknown deco id: ${req.DecoId}`);
208
223
}
209
224
210
225
placedDeco.PictureFrameInfo = req.PictureFrameInfo;
@@ -154,7 +154,7 @@ export interface ISetPlacedDecoInfoRequest {
154
154
DecoId: string;
155
155
Room: string;
156
156
PictureFrameInfo: IPictureFrameInfo;
157
BootLocation?: string;
157
BootLocation?: TBootLocation;
158
158
ComponentId?: string;
159
159
GuildId?: string;
160
160
}