From 8d4abe863c0dedb7604b41b0a89bfff5a36f6a67 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Wed, 8 Oct 2025 08:34:34 +0200 Subject: [PATCH] simplify worldState logic --- src/services/worldStateService.ts | 29 ++++++++++++----------------- src/types/worldStateTypes.ts | 2 +- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/services/worldStateService.ts b/src/services/worldStateService.ts index 742c41c0..526f313b 100644 --- a/src/services/worldStateService.ts +++ b/src/services/worldStateService.ts @@ -113,8 +113,8 @@ const sortieBossNode: Record, SORTIE_BOSS_VOR: "SolNode108" }; -const voidCorruptionAlerts = [ - { +const configAlerts: Record = { + voidCorruptionWeek1: { _id: { $oid: "677d452e2f324ee7b90f8ccf" }, Activation: { $date: { $numberLong: "1736524800000" } }, Expiry: { $date: { $numberLong: "2000000000000" } }, @@ -134,7 +134,7 @@ const voidCorruptionAlerts = [ maxEnemyLevel: 15 } }, - { + voidCorruptionWeek2: { _id: { $oid: "677d45811daeae9de40e8c0f" }, Activation: { $date: { $numberLong: "1737129600000" } }, Expiry: { $date: { $numberLong: "2000000000000" } }, @@ -154,7 +154,7 @@ const voidCorruptionAlerts = [ maxWaveNum: 6 } }, - { + voidCorruptionWeek3: { _id: { $oid: "677d45a494ad716c90006b9a" }, Activation: { $date: { $numberLong: "1737734400000" } }, Expiry: { $date: { $numberLong: "2000000000000" } }, @@ -175,7 +175,7 @@ const voidCorruptionAlerts = [ maxEnemyLevel: 35 } }, - { + voidCorruptionWeek4: { _id: { $oid: "677d4700682d173abb0e19fe" }, Activation: { $date: { $numberLong: "1738339200000" } }, Expiry: { $date: { $numberLong: "2000000000000" } }, @@ -194,7 +194,7 @@ const voidCorruptionAlerts = [ maxEnemyLevel: 45 } } -] satisfies readonly IAlert[]; +}; const eidolonJobs: readonly string[] = [ "/Lotus/Types/Gameplay/Eidolon/Jobs/AssassinateBountyAss", @@ -1566,17 +1566,12 @@ export const getWorldState = (buildLabel?: string): IWorldState => { fullyStockBaro(vt); } - const vcWeeks = [ - ["voidCorruptionWeek1", 0], - ["voidCorruptionWeek2", 1], - ["voidCorruptionWeek3", 2], - ["voidCorruptionWeek4", 3] - ] as const; - - const selected = vcWeeks.filter(([flag]) => config.worldState?.[flag]).map(([, idx]) => voidCorruptionAlerts[idx]); - - if (selected.length) { - worldState.Alerts = [...worldState.Alerts, ...selected]; + if (config.worldState) { + for (const [key, alert] of Object.entries(configAlerts)) { + if (config.worldState[key as keyof typeof config.worldState]) { + worldState.Alerts.push(alert); + } + } } const isFebruary = date.getUTCMonth() == 1; diff --git a/src/types/worldStateTypes.ts b/src/types/worldStateTypes.ts index 77bdc3be..723e8875 100644 --- a/src/types/worldStateTypes.ts +++ b/src/types/worldStateTypes.ts @@ -7,7 +7,7 @@ export interface IWorldState { Time: number; InGameMarket: IInGameMarket; Goals: IGoal[]; - Alerts: readonly IAlert[]; + Alerts: IAlert[]; Sorties: ISortie[]; LiteSorties: ILiteSortie[]; SyndicateMissions: ISyndicateMissionInfo[];