From 3735cff23ff765c7eb9d122e0817e71fc0d023c8 Mon Sep 17 00:00:00 2001 From: Hikari Date: Tue, 31 Mar 2026 10:35:36 -0700 Subject: [PATCH] fix: unlock exploration areas when their zone is unlocked by boss kill or quest (#161) applyBossResult and the tick engine both updated zone status to "unlocked" but never propagated that unlock to state.exploration.areas, leaving all areas in the new zone permanently locked until force-unlock was used. Both code paths now map over exploration areas and set any locked area whose zone just became unlocked to "available" in the same state update. --- apps/web/src/context/gameContext.tsx | 21 +++++++++++++++++++++ apps/web/src/engine/tick.ts | 18 ++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/apps/web/src/context/gameContext.tsx b/apps/web/src/context/gameContext.tsx index 206b84c..04fa573 100644 --- a/apps/web/src/context/gameContext.tsx +++ b/apps/web/src/context/gameContext.tsx @@ -53,6 +53,7 @@ import { transcend as transcendApi, } from "../api/client.js"; import { CODEX_ENTRIES } from "../data/codex.js"; +import { EXPLORATION_AREAS } from "../data/explorations.js"; import { RECIPES } from "../data/recipes.js"; import { RESOURCE_CAP, @@ -116,6 +117,9 @@ const applyBossResult = ( }). filter(Boolean), ); + const newlyUnlockedZoneIds = new Set(unlockedZones.map((z) => { + return z.id; + })); const challengeUpdate = previous.dailyChallenges === undefined @@ -216,6 +220,23 @@ const applyBossResult = ( ? { ...u, unlocked: true } : u; }), + ...newlyUnlockedZoneIds.size === 0 || previous.exploration === undefined + ? {} + : { + exploration: { + ...previous.exploration, + areas: previous.exploration.areas.map((area) => { + const areaDefinition = EXPLORATION_AREAS.find((definition) => { + return definition.id === area.id; + }); + return areaDefinition !== undefined + && newlyUnlockedZoneIds.has(areaDefinition.zoneId) + && area.status === "locked" + ? { ...area, status: "available" as const } + : area; + }), + }, + }, }; } diff --git a/apps/web/src/engine/tick.ts b/apps/web/src/engine/tick.ts index 145e56b..ada6501 100644 --- a/apps/web/src/engine/tick.ts +++ b/apps/web/src/engine/tick.ts @@ -21,6 +21,7 @@ import { getActiveCompanionBonus, } from "@elysium/types"; import { EQUIPMENT_SETS } from "../data/equipmentSets.js"; +import { EXPLORATION_AREAS } from "../data/explorations.js"; import { updateChallengeProgress } from "../utils/dailyChallenges.js"; /** @@ -753,6 +754,23 @@ export const applyTick = ( ...updatedDailyChallenges === undefined ? {} : { dailyChallenges: updatedDailyChallenges }, + ...newlyUnlockedZoneIds.size === 0 || state.exploration === undefined + ? {} + : { + exploration: { + ...state.exploration, + areas: state.exploration.areas.map((area) => { + const areaDefinition = EXPLORATION_AREAS.find((definition) => { + return definition.id === area.id; + }); + return areaDefinition !== undefined + && newlyUnlockedZoneIds.has(areaDefinition.zoneId) + && area.status === "locked" + ? { ...area, status: "available" as const } + : area; + }), + }, + }, adventurers: updatedAdventurers, bosses: updatedBosses, equipment: updatedEquipmentReference,