From 5fedc2ce2b24dda8a6409b7369ee05c3a6e883f8 Mon Sep 17 00:00:00 2001 From: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Date: Sun, 9 Feb 2025 15:30:02 +0100 Subject: [PATCH] feat: support additional mission completion fields Closes #932, Closes #468 --- src/services/missionInventoryUpdateService.ts | 29 +++++++++++++++++++ src/types/requestTypes.ts | 4 +++ 2 files changed, 33 insertions(+) diff --git a/src/services/missionInventoryUpdateService.ts b/src/services/missionInventoryUpdateService.ts index 94968713..0cf0a0c7 100644 --- a/src/services/missionInventoryUpdateService.ts +++ b/src/services/missionInventoryUpdateService.ts @@ -83,6 +83,19 @@ export const addMissionInventoryUpdates = ( if (inventoryUpdates.MissionFailed === true) { return; } + if (inventoryUpdates.RewardInfo && inventoryUpdates.RewardInfo.periodicMissionTag) { + const tag = inventoryUpdates.RewardInfo.periodicMissionTag; + const existingCompletion = inventory.PeriodicMissionCompletions.find(completion => completion.tag === tag); + + if (existingCompletion) { + existingCompletion.date = new Date(); + } else { + inventory.PeriodicMissionCompletions.push({ + tag: tag, + date: new Date() + }); + } + } for (const [key, value] of getEntriesUnsafe(inventoryUpdates)) { if (value === undefined) { logger.error(`Inventory update key ${key} has no value `); @@ -178,6 +191,22 @@ export const addMissionInventoryUpdates = ( }); break; } + case "SyndicateId": { + inventory.CompletedSyndicates.push(value); + break; + } + case "SortieId": { + inventory.CompletedSorties.push(value); + break; + } + case "SeasonChallengeCompletions": + const processedCompletions = value.map(({ challenge, id }) => ({ + challenge: challenge.substring(challenge.lastIndexOf("/") + 1), + id + })); + + inventory.SeasonChallengeHistory.push(...processedCompletions); + break; default: // Equipment XP updates if (equipmentKeys.includes(key as TEquipmentKey)) { diff --git a/src/types/requestTypes.ts b/src/types/requestTypes.ts index 19653e02..01302bdc 100644 --- a/src/types/requestTypes.ts +++ b/src/types/requestTypes.ts @@ -44,6 +44,9 @@ export type IMissionInventoryUpdateRequest = { CrewShipAmmo?: ITypeCount[]; BonusMiscItems?: ITypeCount[]; + SyndicateId?: string; + SortieId?: string; + SeasonChallengeCompletions?: ISeasonChallenge[]; AffiliationChanges?: IAffiliationChange[]; crossPlaySetting?: string; rewardsMultiplier?: number; @@ -100,6 +103,7 @@ export interface IRewardInfo { rewardQualifications?: string; // did a Survival for 5 minutes and this was "1" PurgatoryRewardQualifications?: string; rewardSeed?: number; + periodicMissionTag?: string; } export type IMissionStatus = "GS_SUCCESS" | "GS_FAILURE" | "GS_DUMPED" | "GS_QUIT" | "GS_INTERRUPTED";