From 58e7000954476dcd4396756152e9622ac5d30970 Mon Sep 17 00:00:00 2001 From: Hikari Date: Sat, 7 Mar 2026 12:06:21 -0800 Subject: [PATCH] feat: limit players to one active exploration at a time Server-side: check if any area is already in_progress before allowing a new exploration to start. Client-side: derive hasActiveExploration from the full areas list and disable all Explore buttons (with a tooltip) whilst another area is underway. Closes #9. --- apps/api/src/routes/explore.ts | 5 +++-- apps/web/src/components/game/ExplorationPanel.tsx | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/api/src/routes/explore.ts b/apps/api/src/routes/explore.ts index 0a12eb0..78257ed 100644 --- a/apps/api/src/routes/explore.ts +++ b/apps/api/src/routes/explore.ts @@ -75,8 +75,9 @@ exploreRouter.post("/start", async (context) => { return context.json({ error: "Exploration area not found in state" }, 404); } - if (area.status === "in_progress") { - return context.json({ error: "Exploration already in progress" }, 400); + const anyInProgress = state.exploration.areas.some((a) => a.status === "in_progress"); + if (anyInProgress) { + return context.json({ error: "An exploration is already in progress" }, 400); } if (area.status === "locked") { diff --git a/apps/web/src/components/game/ExplorationPanel.tsx b/apps/web/src/components/game/ExplorationPanel.tsx index fa1cf3c..0f621ed 100644 --- a/apps/web/src/components/game/ExplorationPanel.tsx +++ b/apps/web/src/components/game/ExplorationPanel.tsx @@ -38,6 +38,9 @@ export const ExplorationPanel = (): React.JSX.Element => { const zoneAreas = EXPLORATION_AREAS.filter((a) => a.zoneId === activeZoneId); + const hasActiveExploration = + explorationState?.areas.some((a) => a.status === "in_progress") ?? false; + const handleStart = async (areaId: string): Promise => { setPendingAreaId(areaId); try { @@ -137,8 +140,9 @@ export const ExplorationPanel = (): React.JSX.Element => { {status === "available" && (