From 4b32676bae6d72e8d53fe71151a516c358accbf8 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Wed, 25 Jun 2025 02:14:01 +0200 Subject: [PATCH 1/2] fix: convert placed/removed deco types to inventory type --- src/services/shipCustomizationsService.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/shipCustomizationsService.ts b/src/services/shipCustomizationsService.ts index 47764917..0e506969 100644 --- a/src/services/shipCustomizationsService.ts +++ b/src/services/shipCustomizationsService.ts @@ -13,6 +13,7 @@ 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, @@ -121,7 +122,8 @@ export const handleSetShipDecorations = async ( 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]; + addShipDecorations(inventory, [{ ItemType: itemType, ItemCount: 1 }]); await inventory.save(); } @@ -134,7 +136,8 @@ 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]; + addShipDecorations(inventory, [{ ItemType: itemType, ItemCount: -1 }]); await inventory.save(); } } -- 2.47.2 From 91a92ee1380a44d10ce559555fdb17dd43037c27 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Wed, 25 Jun 2025 02:26:30 +0200 Subject: [PATCH 2/2] handle fusion treasures in personal rooms --- src/models/personalRoomsModel.ts | 1 + src/services/shipCustomizationsService.ts | 24 ++++++++++++++++++----- src/types/shipTypes.ts | 2 ++ 3 files changed, 22 insertions(+), 5 deletions(-) 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 0e506969..a01901fd 100644 --- a/src/services/shipCustomizationsService.ts +++ b/src/services/shipCustomizationsService.ts @@ -8,7 +8,7 @@ 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"; @@ -102,6 +102,7 @@ export const handleSetShipDecorations = async ( Pos: placedDecoration.Pos, Rot: placedDecoration.Rot, Scale: placedDecoration.Scale, + Sockets: placedDecoration.Sockets, _id: placedDecoration.MoveId }; @@ -117,13 +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); - const itemType = Object.entries(ExportResources).find(arr => arr[1].deco == placedDecoration.Type)![0]; - addShipDecorations(inventory, [{ ItemType: itemType, 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(); } @@ -137,7 +144,13 @@ export const handleSetShipDecorations = async ( if (!config.unlockAllShipDecorations) { const inventory = await getInventory(accountId); const itemType = Object.entries(ExportResources).find(arr => arr[1].deco == placedDecoration.Type)![0]; - addShipDecorations(inventory, [{ ItemType: itemType, ItemCount: -1 }]); + if (placedDecoration.Sockets !== undefined) { + addFusionTreasures(inventory, [ + { ItemType: itemType, Sockets: placedDecoration.Sockets, ItemCount: -1 } + ]); + } else { + addShipDecorations(inventory, [{ ItemType: itemType, ItemCount: -1 }]); + } await inventory.save(); } } @@ -151,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 { -- 2.47.2