From b543392f34b38f4b813fd5044e6574eb1d9aaaec Mon Sep 17 00:00:00 2001 From: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:09:22 +0200 Subject: [PATCH] fix: loc-pin saving --- src/models/inventoryModels/inventoryModel.ts | 37 +++++++++++++++++++- src/services/inventoryService.ts | 30 ++++++++++++---- src/types/inventoryTypes/inventoryTypes.ts | 21 +++++++++++ src/types/requestTypes.ts | 4 ++- 4 files changed, 84 insertions(+), 8 deletions(-) diff --git a/src/models/inventoryModels/inventoryModel.ts b/src/models/inventoryModels/inventoryModel.ts index 392952b7..997992a5 100644 --- a/src/models/inventoryModels/inventoryModel.ts +++ b/src/models/inventoryModels/inventoryModel.ts @@ -36,7 +36,10 @@ import { IPeriodicMissionCompletionDatabase, IPeriodicMissionCompletionResponse, ILoreFragmentScan, - IEvolutionProgress + IEvolutionProgress, + ICustomMarkers, + IMarkerInfo, + IMarker } from "../../types/inventoryTypes/inventoryTypes"; import { IOid } from "../../types/commonTypes"; import { @@ -578,6 +581,35 @@ const evolutionProgressSchema = new Schema( { _id: false } ); +const markerSchema = new Schema( + { + anchorName: String, + color: Number, + label: String, + x: Number, + y: Number, + z: Number, + showInHud: Boolean + }, + { _id: false } +); + +const markerInfoSchema = new Schema( + { + icon: String, + markers: [markerSchema] + }, + { _id: false } +); + +const CustomMarkersSchema = new Schema( + { + tag: String, + markerInfos: [markerInfoSchema] + }, + { _id: false } +); + const inventorySchema = new Schema( { accountOwnerId: Schema.Types.ObjectId, @@ -900,6 +932,9 @@ const inventorySchema = new Schema( //https://warframe.fandom.com/wiki/Incarnon EvolutionProgress: { type: [evolutionProgressSchema], default: undefined }, + //https://warframe.fandom.com/wiki/Loc-Pin + CustomMarkers: [CustomMarkersSchema], + //Unknown and system DuviriInfo: DuviriInfoSchema, Mailbox: MailboxSchema, diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index b7a1059f..b0118988 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -731,7 +731,11 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques Consumables, Recipes, Missions, - FusionTreasures + FusionTreasures, + AffiliationChanges, + EvolutionProgress, + LastRegionPlayed, + CustomMarkers } = data; const inventory = await getInventory(accountId); @@ -742,7 +746,7 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques inventory.FusionPoints += FusionPoints || 0; // syndicate - data.AffiliationChanges?.forEach(affiliation => { + AffiliationChanges?.forEach(affiliation => { const syndicate = inventory.Affiliations.find(x => x.Tag == affiliation.Tag); if (syndicate !== undefined) { syndicate.Standing = @@ -763,8 +767,8 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques equipmentKeys.forEach(key => addGearExpByCategory(inventory, data[key], key)); // Incarnon Challenges - if (data.EvolutionProgress) { - for (const evoProgress of data.EvolutionProgress) { + if (EvolutionProgress) { + for (const evoProgress of EvolutionProgress) { const entry = inventory.EvolutionProgress ? inventory.EvolutionProgress.find(entry => entry.ItemType == evoProgress.ItemType) : undefined; @@ -779,8 +783,22 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques } // LastRegionPlayed - if (data.LastRegionPlayed) { - inventory.LastRegionPlayed = data.LastRegionPlayed; + if (LastRegionPlayed) { + inventory.LastRegionPlayed = LastRegionPlayed; + } + + if (CustomMarkers) { + CustomMarkers.forEach(markers => { + const map = inventory.CustomMarkers + ? inventory.CustomMarkers.find(entry => entry.tag == markers.tag) + : undefined; + if (map) { + map.markerInfos = markers.markerInfos; + } else { + inventory.CustomMarkers ??= []; + inventory.CustomMarkers.push(markers); + } + }); } // other diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index 1367868f..eb5bb1fd 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -277,6 +277,7 @@ export interface IInventoryResponse { LastInventorySync: IOid; NextRefill: IMongoDate; // Next time argon crystals will have a decay tick FoundToday?: IMiscItem[]; // for Argon Crystals + CustomMarkers: ICustomMarkers[]; ActiveLandscapeTraps: any[]; EvolutionProgress?: IEvolutionProgress[]; RepVotes: any[]; @@ -916,3 +917,23 @@ export interface IEvolutionProgress { Rank: number; ItemType: string; } + +export interface ICustomMarkers { + tag: string; + markerInfos: IMarkerInfo[]; +} + +export interface IMarkerInfo { + icon: string; + markers: IMarker[]; +} + +export interface IMarker { + anchorName: string; + color: number; + label?: string; + x: number; + y: number; + z: number; + showInHud: boolean; +} diff --git a/src/types/requestTypes.ts b/src/types/requestTypes.ts index 288bb99c..796a186e 100644 --- a/src/types/requestTypes.ts +++ b/src/types/requestTypes.ts @@ -13,7 +13,8 @@ import { ISeasonChallenge, TSolarMapRegion, TEquipmentKey, - IFusionTreasure + IFusionTreasure, + ICustomMarkers } from "./inventoryTypes/inventoryTypes"; export interface IArtifactsRequest { @@ -70,6 +71,7 @@ export interface IMissionInventoryUpdateRequest { Missions?: IMission; EvolutionProgress?: IEvolutionProgress[]; LastRegionPlayed?: TSolarMapRegion; + CustomMarkers?: ICustomMarkers[]; FusionPoints?: number; // Not a part of the request, but we put it in this struct as an intermediate storage. }