diff --git a/src/models/personalRoomsModel.ts b/src/models/personalRoomsModel.ts index 9a19d06b..20f94a9a 100644 --- a/src/models/personalRoomsModel.ts +++ b/src/models/personalRoomsModel.ts @@ -40,6 +40,7 @@ const placedDecosSchema = new Schema( Pos: [Number], Rot: [Number], Scale: Number, + Sockets: Number, PictureFrameInfo: { type: pictureFrameInfoSchema, default: undefined } }, { id: false } diff --git a/src/services/shipCustomizationsService.ts b/src/services/shipCustomizationsService.ts index 47764917..a01901fd 100644 --- a/src/services/shipCustomizationsService.ts +++ b/src/services/shipCustomizationsService.ts @@ -8,11 +8,12 @@ import { } from "@/src/types/shipTypes"; import { logger } from "@/src/utils/logger"; import { Types } from "mongoose"; -import { addShipDecorations, getInventory } from "./inventoryService"; +import { addFusionTreasures, addShipDecorations, getInventory } from "./inventoryService"; import { config } from "./configService"; import { Guild } from "../models/guildModel"; import { hasGuildPermission } from "./guildService"; import { GuildPermission } from "../types/guildTypes"; +import { ExportResources } from "warframe-public-export-plus"; export const setShipCustomizations = async ( accountId: string, @@ -101,6 +102,7 @@ export const handleSetShipDecorations = async ( Pos: placedDecoration.Pos, Rot: placedDecoration.Rot, Scale: placedDecoration.Scale, + Sockets: placedDecoration.Sockets, _id: placedDecoration.MoveId }; @@ -116,12 +118,19 @@ export const handleSetShipDecorations = async ( } if (placedDecoration.RemoveId) { - roomToPlaceIn.PlacedDecos.pull({ _id: placedDecoration.RemoveId }); + const decoIndex = roomToPlaceIn.PlacedDecos.findIndex(x => x._id.equals(placedDecoration.RemoveId)); + const deco = roomToPlaceIn.PlacedDecos[decoIndex]; + roomToPlaceIn.PlacedDecos.splice(decoIndex, 1); await personalRooms.save(); if (!config.unlockAllShipDecorations) { const inventory = await getInventory(accountId); - addShipDecorations(inventory, [{ ItemType: placedDecoration.Type, ItemCount: 1 }]); + const itemType = Object.entries(ExportResources).find(arr => arr[1].deco == deco.Type)![0]; + if (deco.Sockets !== undefined) { + addFusionTreasures(inventory, [{ ItemType: itemType, Sockets: deco.Sockets, ItemCount: 1 }]); + } else { + addShipDecorations(inventory, [{ ItemType: itemType, ItemCount: 1 }]); + } await inventory.save(); } @@ -134,7 +143,14 @@ export const handleSetShipDecorations = async ( } else { if (!config.unlockAllShipDecorations) { const inventory = await getInventory(accountId); - addShipDecorations(inventory, [{ ItemType: placedDecoration.Type, ItemCount: -1 }]); + const itemType = Object.entries(ExportResources).find(arr => arr[1].deco == placedDecoration.Type)![0]; + if (placedDecoration.Sockets !== undefined) { + addFusionTreasures(inventory, [ + { ItemType: itemType, Sockets: placedDecoration.Sockets, ItemCount: -1 } + ]); + } else { + addShipDecorations(inventory, [{ ItemType: itemType, ItemCount: -1 }]); + } await inventory.save(); } } @@ -148,6 +164,7 @@ export const handleSetShipDecorations = async ( Pos: placedDecoration.Pos, Rot: placedDecoration.Rot, Scale: placedDecoration.Scale, + Sockets: placedDecoration.Sockets, _id: decoId }); diff --git a/src/types/shipTypes.ts b/src/types/shipTypes.ts index 74eaaeae..6ac738b2 100644 --- a/src/types/shipTypes.ts +++ b/src/types/shipTypes.ts @@ -96,6 +96,7 @@ export interface IPlacedDecosDatabase { Pos: [number, number, number]; Rot: [number, number, number]; Scale?: number; + Sockets?: number; PictureFrameInfo?: IPictureFrameInfo; _id: Types.ObjectId; } @@ -136,6 +137,7 @@ export interface IShipDecorationsRequest { MoveId?: string; OldRoom?: string; Scale?: number; + Sockets?: number; } export interface IShipDecorationsResponse {