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

XFESpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/XFESpaceNinjaServer

fix: remove ship decos from inventory when placed and vice-versa (#770)

e201279e
Sainan <sainan@calamity.inc>
提交于

代码差异

1 个文件 +15 -2
Modified src/services/shipCustomizationsService.ts +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