XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

fix: properly convert personal room decos to and from inventory types (#2279)

Closes #2277 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2279 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

39630c5a
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

3 个文件 +24 -4
Modified src/models/personalRoomsModel.ts +1 -0
@@ -40,6 +40,7 @@ const placedDecosSchema = new Schema<IPlacedDecosDatabase>(
40 40 Pos: [Number],
41 41 Rot: [Number],
42 42 Scale: Number,
43 Sockets: Number,
43 44 PictureFrameInfo: { type: pictureFrameInfoSchema, default: undefined }
44 45 },
45 46 { id: false }
Modified src/services/shipCustomizationsService.ts +21 -4
@@ -8,11 +8,12 @@ import {
8 8 } from "@/src/types/shipTypes";
9 9 import { logger } from "@/src/utils/logger";
10 10 import { Types } from "mongoose";
11 import { addShipDecorations, getInventory } from "./inventoryService";
11 import { addFusionTreasures, addShipDecorations, getInventory } from "./inventoryService";
12 12 import { config } from "./configService";
13 13 import { Guild } from "../models/guildModel";
14 14 import { hasGuildPermission } from "./guildService";
15 15 import { GuildPermission } from "../types/guildTypes";
16 import { ExportResources } from "warframe-public-export-plus";
16 17
17 18 export const setShipCustomizations = async (
18 19 accountId: string,
@@ -101,6 +102,7 @@ export const handleSetShipDecorations = async (
101 102 Pos: placedDecoration.Pos,
102 103 Rot: placedDecoration.Rot,
103 104 Scale: placedDecoration.Scale,
105 Sockets: placedDecoration.Sockets,
104 106 _id: placedDecoration.MoveId
105 107 };
106 108
@@ -116,12 +118,19 @@ export const handleSetShipDecorations = async (
116 118 }
117 119
118 120 if (placedDecoration.RemoveId) {
119 roomToPlaceIn.PlacedDecos.pull({ _id: placedDecoration.RemoveId });
121 const decoIndex = roomToPlaceIn.PlacedDecos.findIndex(x => x._id.equals(placedDecoration.RemoveId));
122 const deco = roomToPlaceIn.PlacedDecos[decoIndex];
123 roomToPlaceIn.PlacedDecos.splice(decoIndex, 1);
120 124 await personalRooms.save();
121 125
122 126 if (!config.unlockAllShipDecorations) {
123 127 const inventory = await getInventory(accountId);
124 addShipDecorations(inventory, [{ ItemType: placedDecoration.Type, ItemCount: 1 }]);
128 const itemType = Object.entries(ExportResources).find(arr => arr[1].deco == deco.Type)![0];
129 if (deco.Sockets !== undefined) {
130 addFusionTreasures(inventory, [{ ItemType: itemType, Sockets: deco.Sockets, ItemCount: 1 }]);
131 } else {
132 addShipDecorations(inventory, [{ ItemType: itemType, ItemCount: 1 }]);
133 }
125 134 await inventory.save();
126 135 }
127 136
@@ -134,7 +143,14 @@ export const handleSetShipDecorations = async (
134 143 } else {
135 144 if (!config.unlockAllShipDecorations) {
136 145 const inventory = await getInventory(accountId);
137 addShipDecorations(inventory, [{ ItemType: placedDecoration.Type, ItemCount: -1 }]);
146 const itemType = Object.entries(ExportResources).find(arr => arr[1].deco == placedDecoration.Type)![0];
147 if (placedDecoration.Sockets !== undefined) {
148 addFusionTreasures(inventory, [
149 { ItemType: itemType, Sockets: placedDecoration.Sockets, ItemCount: -1 }
150 ]);
151 } else {
152 addShipDecorations(inventory, [{ ItemType: itemType, ItemCount: -1 }]);
153 }
138 154 await inventory.save();
139 155 }
140 156 }
@@ -148,6 +164,7 @@ export const handleSetShipDecorations = async (
148 164 Pos: placedDecoration.Pos,
149 165 Rot: placedDecoration.Rot,
150 166 Scale: placedDecoration.Scale,
167 Sockets: placedDecoration.Sockets,
151 168 _id: decoId
152 169 });
153 170
Modified src/types/shipTypes.ts +2 -0
@@ -96,6 +96,7 @@ export interface IPlacedDecosDatabase {
96 96 Pos: [number, number, number];
97 97 Rot: [number, number, number];
98 98 Scale?: number;
99 Sockets?: number;
99 100 PictureFrameInfo?: IPictureFrameInfo;
100 101 _id: Types.ObjectId;
101 102 }
@@ -136,6 +137,7 @@ export interface IShipDecorationsRequest {
136 137 MoveId?: string;
137 138 OldRoom?: string;
138 139 Scale?: number;
140 Sockets?: number;
139 141 }
140 142
141 143 export interface IShipDecorationsResponse {