diff --git a/docs/rules-status.md b/docs/rules-status.md index 7d6c671..bdad507 100644 --- a/docs/rules-status.md +++ b/docs/rules-status.md @@ -79,3 +79,5 @@ Sound effects combine a CC0 recording of real dice throws (see `audio-credits.md All seven layouts were transcribed from the supplied production scenario fronts. Layout tests cover every player count, unique terrain cards, five/six village tiles, seven equipment markers, two eruption markers, connected maps and both starting positions. All seven maps were rendered in the harness. Adaptation rule: a player with no other reachable, unclaimed destination may confirm staying despite a neighbor sharing that destination. This prevents isolated players from stalling planning before lava ends the expedition. Normal destination restrictions still apply when another route is available. + +Validation: 1,050 completed expeditions across all seven scenarios, 2–4 players and four difficulty levels; 68,793 moves, 122 victories, no deadlocks and exact replays. All 70 engine tests pass. diff --git a/packages/viewer/src/lib/Landscape.svelte b/packages/viewer/src/lib/Landscape.svelte index cf0315a..5bd9310 100644 --- a/packages/viewer/src/lib/Landscape.svelte +++ b/packages/viewer/src/lib/Landscape.svelte @@ -28,15 +28,25 @@ } = $props(); const danger = $derived(threatened(state)); const mapWidth = $derived(116 + Math.max(...state.board.map((c) => c.x)) * 100); - // Use empty map space without adding a footer where the layout allows it. - const guidePosition = $derived( - ({ 1: [14, 519], 2: [14, 603], 3: [14, 519] } as Record)[state.scenario ?? 1] - ); - const guideX = $derived(guidePosition?.[0] ?? 14); - const guideY = $derived(guidePosition?.[1] ?? 100 + Math.max(...state.board.map((c) => c.y)) * 84); - const mapHeight = $derived( - Math.max(100 + Math.max(...state.board.map((c) => c.y)) * 84, guideY + (state.difficulty >= 3 ? 111 : 91)) + // Empty rectangles in the seven production layouts, including four-player tiles. + const layout = $derived( + ( + { + 1: { guide: [14, 519, 385], counter: [114, 16] }, + 2: { guide: [14, 603, 485], counter: [714, 16] }, + 3: { guide: [14, 519, 485], counter: [314, 16] }, + 4: { guide: [514, 435, 185], counter: [714, 16] }, + 5: { guide: [414, 519, 185], counter: [714, 16] }, + 6: { guide: [14, 351, 285], counter: [714, 16] }, + 7: { guide: [214, 267, 285], counter: [714, 16] }, + } as Record + )[state.scenario ?? 1]! ); + const guideX = $derived(layout.guide[0]!); + const guideY = $derived(layout.guide[1]!); + const guideWidth = $derived(layout.guide[2]!); + const guideHeight = $derived(guideWidth < 200 ? 184 : guideWidth < 300 ? 148 : state.difficulty >= 3 ? 106 : 86); + const mapHeight = $derived(Math.max(100 + Math.max(...state.board.map((c) => c.y)) * 84, guideY + guideHeight + 5)); const x = (id: string) => 58 + cell(state, id).x * 100; const y = (id: string) => 54 + cell(state, id).y * 84; const edges = $derived( @@ -53,35 +63,11 @@
-
- THE FUJI TRAIL -
- Scenario {String(state.scenario ?? 1).padStart(2, "0")} · Level {state.difficulty} terrain(cell(state, p.position).terrain).kind === "village").length} of ${state.players.length} players in the village`} - > - - {state.players.filter((p) => terrain(cell(state, p.position).terrain).kind === "village").length}/{state.players - .length} -
-
{/if} {/each} - = 3 ? 106 : 86} class="map-guides"> + +
terrain(cell(state, p.position).terrain).kind === "village").length} of ${state.players.length} players in the village`} + > + + {state.players.filter((p) => terrain(cell(state, p.position).terrain).kind === "village").length}/{state + .players.length} +
+
+
- {#if state.phase === "setup"}Map preview · choose your equipment first{:else}Your route{/if}Next eruption + RouteNext eruption
@@ -292,29 +295,9 @@ var(--landscape-art) center/cover; z-index: -1; } - .scene-meta { - display: flex; - align-items: center; - gap: 20px; - margin-left: auto; - } - .scene-caption { - flex-wrap: wrap; - gap: 10px; - display: flex; - justify-content: space-between; - align-items: center; - padding: 23px 26px 0; - font-size: 12px; - color: #a1b5a4; - } - .dot { - margin: 0 5px; - color: #cfb873; - } .map { width: 100%; - height: clamp(500px, calc(100vh - 310px), 760px); + height: clamp(500px, calc(100vh - 265px), 760px); display: block; } @@ -478,7 +461,7 @@ flex-wrap: wrap; padding: 0 0 10px; display: flex; - gap: 20px; + gap: 8px 16px; color: #a7b9a8; font-size: 12px; align-items: center; @@ -534,9 +517,6 @@ min-width: 610px; height: auto; } - .scene-caption { - padding: 16px 16px 0; - } .scene-legend { padding: 0 0 10px; gap: 12px; diff --git a/tests/scenarios-browser.mjs b/tests/scenarios-browser.mjs new file mode 100644 index 0000000..e129928 --- /dev/null +++ b/tests/scenarios-browser.mjs @@ -0,0 +1,34 @@ +import { chromium } from "playwright"; +import { initGame } from "../packages/engine/dist/index.js"; +import assert from "node:assert/strict"; +import fs from "node:fs"; +fs.mkdirSync("work/browser", { recursive: true }); +const browser = await chromium.launch({ executablePath: process.env.FUJI_CHROMIUM_EXECUTABLE }); +for (const difficulty of [1, 4]) + for (let scenario = 1; scenario <= 7; scenario++) { + const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } }); + const state = initGame(4, { scenario, difficulty }, "scenario-preview"); + await page.addInitScript((s) => localStorage.setItem("fuji-dev-v1", JSON.stringify(s)), state); + await page.goto("http://127.0.0.1:5187"); + await page.locator(".map").waitFor(); + assert((await page.locator(".map").getAttribute("aria-label")).includes("Scenario " + scenario)); + assert.equal(await page.locator(".location").count(), state.board.length); + assert.equal((await page.locator(".legend-end").innerText()).trim(), "0/4"); + await page.screenshot({ path: `work/browser/scenario-${scenario}-level-${difficulty}.png`, fullPage: true }); + const guide = await page.locator(".map-guides").evaluate((el) => ({ + height: el.height.baseVal.value, + actual: el.firstElementChild.getBoundingClientRect().height / el.getScreenCTM().a, + })); + assert(guide.actual <= guide.height + 1, JSON.stringify({ scenario, difficulty, guide })); + await page.setViewportSize({ width: 390, height: 844 }); + assert.equal( + await page.evaluate(() => document.documentElement.scrollWidth > innerWidth), + false, + `Mobile overflow: ${scenario}/${difficulty}` + ); + await page.close(); + } +await browser.close(); +console.log( + "All seven layouts verified at difficulty 1 and 4, with village counters, unclipped guides and no mobile page overflow." +);