返回提交历史
Modified
src/services/shipCustomizationsService.ts
+15
-2
XFEstudio/XFESpaceNinjaServer
fix: remove ship decos from inventory when placed and vice-versa (#770)
e201279e
代码差异
1 个文件
+15
-2
@@ -8,6 +8,8 @@ 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";
12
import { config } from "./configService";
11
13
12
14
export const setShipCustomizations = async (
13
15
accountId: string,
@@ -106,17 +108,28 @@ export const handleSetShipDecorations = async (
106
108
};
107
109
}
108
110
109
//TODO: check whether to remove from shipitems
110
111
111
if (placedDecoration.RemoveId) {
112
112
roomToPlaceIn.PlacedDecos.pull({ _id: placedDecoration.RemoveId });
113
113
await personalRooms.save();
114
115
if (!config.unlockAllShipDecorations) {
116
const inventory = await getInventory(accountId);
117
addShipDecorations(inventory, [{ ItemType: placedDecoration.Type, ItemCount: 1 }]);
118
await inventory.save();
119
}
120
114
121
return {
115
122
DecoId: placedDecoration.RemoveId,
116
123
Room: placedDecoration.Room,
117
124
IsApartment: placedDecoration.IsApartment,
118
125
MaxCapacityIncrease: 0
119
126
};
127
} else {
128
if (!config.unlockAllShipDecorations) {
129
const inventory = await getInventory(accountId);
130
addShipDecorations(inventory, [{ ItemType: placedDecoration.Type, ItemCount: -1 }]);
131
await inventory.save();
132
}
120
133
}
121
134
122
135
// TODO: handle capacity