fix: remove ship decos from inventory when placed and vice-versa (#770)
This commit is contained in:
parent
5cbececb04
commit
e201279eee
@ -8,6 +8,8 @@ import {
|
|||||||
} from "@/src/types/shipTypes";
|
} from "@/src/types/shipTypes";
|
||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
|
import { addShipDecorations, getInventory } from "./inventoryService";
|
||||||
|
import { config } from "./configService";
|
||||||
|
|
||||||
export const setShipCustomizations = async (
|
export const setShipCustomizations = async (
|
||||||
accountId: string,
|
accountId: string,
|
||||||
@ -106,17 +108,28 @@ export const handleSetShipDecorations = async (
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: check whether to remove from shipitems
|
|
||||||
|
|
||||||
if (placedDecoration.RemoveId) {
|
if (placedDecoration.RemoveId) {
|
||||||
roomToPlaceIn.PlacedDecos.pull({ _id: placedDecoration.RemoveId });
|
roomToPlaceIn.PlacedDecos.pull({ _id: placedDecoration.RemoveId });
|
||||||
await personalRooms.save();
|
await personalRooms.save();
|
||||||
|
|
||||||
|
if (!config.unlockAllShipDecorations) {
|
||||||
|
const inventory = await getInventory(accountId);
|
||||||
|
addShipDecorations(inventory, [{ ItemType: placedDecoration.Type, ItemCount: 1 }]);
|
||||||
|
await inventory.save();
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
DecoId: placedDecoration.RemoveId,
|
DecoId: placedDecoration.RemoveId,
|
||||||
Room: placedDecoration.Room,
|
Room: placedDecoration.Room,
|
||||||
IsApartment: placedDecoration.IsApartment,
|
IsApartment: placedDecoration.IsApartment,
|
||||||
MaxCapacityIncrease: 0
|
MaxCapacityIncrease: 0
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
if (!config.unlockAllShipDecorations) {
|
||||||
|
const inventory = await getInventory(accountId);
|
||||||
|
addShipDecorations(inventory, [{ ItemType: placedDecoration.Type, ItemCount: -1 }]);
|
||||||
|
await inventory.save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: handle capacity
|
// TODO: handle capacity
|
||||||
|
Loading…
x
Reference in New Issue
Block a user