diff --git a/src/services/importService.ts b/src/services/importService.ts index a3141073..e1f8a7c3 100644 --- a/src/services/importService.ts +++ b/src/services/importService.ts @@ -2,6 +2,7 @@ import { Types } from "mongoose"; import { IEquipmentClient, IEquipmentDatabase, + IItemConfig, IOperatorConfigClient, IOperatorConfigDatabase } from "../types/inventoryTypes/commonInventoryTypes"; @@ -174,6 +175,20 @@ const convertNemesis = (client: INemesisClient): INemesisDatabase => { }; }; +// Empty objects from live may have been encoded as an empty array because of PHP. +export const convertItemConfig = (client: T): T => { + return { + ...client, + pricol: Array.isArray(client.pricol) ? {} : client.pricol, + attcol: Array.isArray(client.attcol) ? {} : client.attcol, + sigcol: Array.isArray(client.sigcol) ? {} : client.sigcol, + eyecol: Array.isArray(client.eyecol) ? {} : client.eyecol, + facial: Array.isArray(client.facial) ? {} : client.facial, + cloth: Array.isArray(client.cloth) ? {} : client.cloth, + syancol: Array.isArray(client.syancol) ? {} : client.syancol + }; +}; + export const importInventory = (db: TInventoryDatabaseDocument, client: Partial): void => { for (const key of equipmentKeys) { if (client[key] !== undefined) { @@ -352,7 +367,7 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial< db.PlayerSkills = client.PlayerSkills; } if (client.LotusCustomization !== undefined) { - db.LotusCustomization = client.LotusCustomization; + db.LotusCustomization = convertItemConfig(client.LotusCustomization); } if (client.CollectibleSeries !== undefined) { db.CollectibleSeries = client.CollectibleSeries;