From 58156b04577ae7f9786ab215ded654ca554afd53 Mon Sep 17 00:00:00 2001 From: Sainan Date: Mon, 20 Jan 2025 08:32:39 +0100 Subject: [PATCH] import DialogueHistory --- src/services/importService.ts | 24 ++++++++++++++++++++++ src/types/inventoryTypes/inventoryTypes.ts | 4 +++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/services/importService.ts b/src/services/importService.ts index 037a9eb6..803e0ab2 100644 --- a/src/services/importService.ts +++ b/src/services/importService.ts @@ -8,6 +8,10 @@ import { import { IMongoDate } from "../types/commonTypes"; import { equipmentKeys, + IDialogueClient, + IDialogueDatabase, + IDialogueHistoryClient, + IDialogueHistoryDatabase, IInfestedFoundryClient, IInfestedFoundryDatabase, IInventoryClient, @@ -85,6 +89,23 @@ const convertInfestedFoundry = (client: IInfestedFoundryClient): IInfestedFoundr }; }; +const convertDialogue = (client: IDialogueClient): IDialogueDatabase => { + return { + ...client, + AvailableDate: convertDate(client.AvailableDate), + AvailableGiftDate: convertDate(client.AvailableGiftDate), + RankUpExpiry: convertDate(client.RankUpExpiry), + BountyChemExpiry: convertDate(client.BountyChemExpiry) + }; +}; + +const convertDialogueHistory = (client: IDialogueHistoryClient): IDialogueHistoryDatabase => { + return { + YearIteration: client.YearIteration, + Dialogues: client.Dialogues ? client.Dialogues.map(convertDialogue) : undefined + }; +}; + export const importInventory = (db: TInventoryDatabaseDocument, client: Partial): void => { for (const key of equipmentKeys) { if (client[key]) { @@ -150,6 +171,9 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial< if (client.InfestedFoundry) { db.InfestedFoundry = convertInfestedFoundry(client.InfestedFoundry); } + if (client.DialogueHistory) { + db.DialogueHistory = convertDialogueHistory(client.DialogueHistory); + } }; const convertLoadOutConfig = (client: ILoadoutConfigClient): ILoadoutConfigDatabase => { diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index 44c41dab..9d5e10c8 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -31,6 +31,7 @@ export interface IInventoryDatabase | "OperatorLoadOuts" | "AdultOperatorLoadOuts" | "InfestedFoundry" + | "DialogueHistory" | TEquipmentKey > { accountOwnerId: Types.ObjectId; @@ -50,6 +51,7 @@ export interface IInventoryDatabase OperatorLoadOuts: IOperatorConfigDatabase[]; AdultOperatorLoadOuts: IOperatorConfigDatabase[]; InfestedFoundry?: IInfestedFoundryDatabase; + DialogueHistory?: IDialogueHistoryDatabase; Suits: IEquipmentDatabase[]; LongGuns: IEquipmentDatabase[]; @@ -334,7 +336,7 @@ export interface IInventoryClient extends IDailyAffiliations { Harvestable: boolean; DeathSquadable: boolean; EndlessXP?: IEndlessXpProgress[]; - DialogueHistory?: IDialogueHistoryDatabase; + DialogueHistory?: IDialogueHistoryClient; } export interface IAffiliation {