Add Fuji victory lesson and a petal celebration
This commit is contained in:
parent
dbe5ea819d
commit
b9f2eef696
11 changed files with 342 additions and 28 deletions
|
|
@ -27,9 +27,9 @@ The engine tests cover deterministic replay, invalid-move atomicity, private inf
|
|||
|
||||
## Tutorial
|
||||
|
||||
Open `http://127.0.0.1:5187/tutorial.html?chapter=first-steps` to play a lesson. Each chapter uses the real engine, a prepared position and scripted teammates. Progress resumes separately for each chapter; the guide offers hints and restart controls.
|
||||
Open `http://127.0.0.1:5187/tutorial.html?chapter=first-steps` to play a lesson. Each chapter uses the real engine, a prepared position and scripted teammates. Progress resumes separately for each chapter; playback controls let you go back, replay a step or start over.
|
||||
|
||||
`pnpm build` produces one viewer JS/CSS bundle for games and tutorials. Upload it as the viewer with global name `fuji`, then add these chapters under **Tutorial** in BGS admin (revision `2` for chapters 1–3, `5` for chapter 4):
|
||||
`pnpm build` produces one viewer JS/CSS bundle for games and tutorials. Upload it as the viewer with global name `fuji`, then add these chapters under **Tutorial** in BGS admin (revision `2` for chapters 1–3, `5` for chapter 4, `1` for chapter 5):
|
||||
|
||||
| ID | Title | Covers |
|
||||
| ----------------- | ---------------------------------- | ------------------------------------------------------------------------------- |
|
||||
|
|
@ -37,6 +37,7 @@ Open `http://127.0.0.1:5187/tutorial.html?chapter=first-steps` to play a lesson.
|
|||
| `equipment` | Equipment & helping teammates | Shovel, Map, card timing, discards and private loans. |
|
||||
| `terrain-bonuses` | Location bonuses & supplies | Bonus rerolls, equipment tokens and next-round availability. |
|
||||
| `lava` | When two lava waves catch the team | A deliberate defeat: an extra eruption plus the normal wave catches a teammate. |
|
||||
| `village` | Everyone reaches the village | A team victory, with all three explorers completing their final journeys. |
|
||||
|
||||
Chapter sources: `packages/viewer/src/tutorial/first-steps.ts` and `lessons.ts`. Keep setup and teammate actions deterministic; bump the chapter revision for incompatible changes. `pnpm check` tests legal actions, lesson outcomes, hidden information and saved progress. `node tests/tutorial-browser.mjs` completes every chapter on desktop and mobile. BGS calls `fuji.launchTutorial` for local lessons and `fuji.launch` for multiplayer games.
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
"test:tutorial": "node --test src/tutorial/*.spec.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.3.0",
|
||||
"@boardgamers/protocol": "0.3.1",
|
||||
"fuji-engine": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
import PlayerChoices from "./lib/PlayerChoices.svelte";
|
||||
import TravelGuide from "./lib/TravelGuide.svelte";
|
||||
import StaminaGuide from "./lib/StaminaGuide.svelte";
|
||||
import VictoryPetals from "./lib/VictoryPetals.svelte";
|
||||
let { store }: { store: Store } = $props();
|
||||
const s = $derived(store.scene ?? store.state);
|
||||
const actingSeats = $derived(
|
||||
|
|
@ -425,6 +426,7 @@
|
|||
{/snippet}
|
||||
|
||||
{#if s}
|
||||
<VictoryPetals won={s.outcome === "won"} animating={store.animating} />
|
||||
<main class="expedition">
|
||||
<div class="game-tools">
|
||||
<div class="round-status">
|
||||
|
|
|
|||
93
packages/viewer/src/lib/VictoryPetals.svelte
Normal file
93
packages/viewer/src/lib/VictoryPetals.svelte
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
<script lang="ts">
|
||||
import { onDestroy } from "svelte";
|
||||
|
||||
let { won, animating }: { won: boolean; animating: boolean } = $props();
|
||||
let visible = $state(false);
|
||||
let initialized = false;
|
||||
let previousWin = false;
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
const petals = Array.from({ length: 36 }, (_, i) => ({
|
||||
left: (i * 37 + 4) % 100,
|
||||
drift: ((i % 7) - 3) * 24,
|
||||
delay: ((i * 13) % 10) / 10,
|
||||
duration: 3.7 + (i % 5) * 0.25,
|
||||
color: ["#f2bccb", "#e5a2b6", "#f5dfbb"][i % 3],
|
||||
}));
|
||||
|
||||
$effect(() => {
|
||||
if (animating) return;
|
||||
const entering = initialized && won && !previousWin;
|
||||
initialized = true;
|
||||
previousWin = won;
|
||||
if (!won) {
|
||||
clearTimeout(timer);
|
||||
visible = false;
|
||||
}
|
||||
if (entering && !window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
||||
visible = true;
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => (visible = false), 6000);
|
||||
}
|
||||
});
|
||||
onDestroy(() => clearTimeout(timer));
|
||||
</script>
|
||||
|
||||
{#if visible}
|
||||
<div class="victory-petals" aria-hidden="true">
|
||||
{#each petals as petal, i}
|
||||
<span
|
||||
class="petal"
|
||||
style:left={`${petal.left}%`}
|
||||
style:--drift={`${petal.drift}px`}
|
||||
style:--turn={`${i % 2 ? -280 : 320}deg`}
|
||||
style:animation-delay={`${petal.delay}s`}
|
||||
style:animation-duration={`${petal.duration}s`}
|
||||
><i style:background={petal.color} style:transform={`rotate(${i * 47}deg)`}></i></span
|
||||
>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.victory-petals {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 45;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
.petal {
|
||||
position: absolute;
|
||||
top: -24px;
|
||||
opacity: 0;
|
||||
animation: drift-down ease-in forwards;
|
||||
}
|
||||
.petal i {
|
||||
display: block;
|
||||
width: 13px;
|
||||
height: 9px;
|
||||
border-radius: 70% 15% 70% 35%;
|
||||
box-shadow: inset -2px -1px 2px #754b4b22;
|
||||
}
|
||||
@keyframes drift-down {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translate3d(0, 0, 0) rotate(0deg);
|
||||
}
|
||||
15% {
|
||||
opacity: 0.85;
|
||||
}
|
||||
75% {
|
||||
opacity: 0.7;
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
transform: translate3d(var(--drift), 110vh, 0) rotate(var(--turn));
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.victory-petals {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -128,7 +128,7 @@ export const firstSteps: TutorialOptions<State, Move> = {
|
|||
{
|
||||
id: "welcome",
|
||||
title: "Escape together",
|
||||
text: "Help everyone reach the village before the lava catches anyone. You control the gold explorer; Mika and Ren are scripted teammates. Preparation is done — let’s plan your first move.",
|
||||
text: "Help everyone reach the village before the lava catches anyone. You control the gold explorer; Mika and Ren are scripted teammates. Preparation is done. Let’s plan your first move.",
|
||||
target: "board",
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,15 @@ import { test } from "node:test";
|
|||
import assert from "node:assert/strict";
|
||||
import { createTutorial } from "@boardgamers/protocol/tutorial";
|
||||
import { applyMove, cell, paths, stripSecret, terrain, threatened } from "fuji-engine";
|
||||
import { equipmentLesson, terrainLesson, lavaLesson, BONUS_TILE, ERUPTION_TILE } from "./lessons.ts";
|
||||
import {
|
||||
equipmentLesson,
|
||||
terrainLesson,
|
||||
lavaLesson,
|
||||
BONUS_TILE,
|
||||
ERUPTION_TILE,
|
||||
winLesson,
|
||||
WIN_DESTINATION,
|
||||
} from "./lessons.ts";
|
||||
|
||||
test("equipment teaches a legal turn and private loan, with cards discarded once", async () => {
|
||||
const c = await createTutorial(equipmentLesson);
|
||||
|
|
@ -105,3 +113,23 @@ test("automatic movement cannot save a plan caught by the extra plus normal erup
|
|||
assert.equal(c.snapshot.canContinue, false);
|
||||
assert.equal(c.snapshot.completed, true, c.snapshot.error);
|
||||
});
|
||||
|
||||
test("all three explorers reach the village and win before another eruption", async () => {
|
||||
const c = await createTutorial(winLesson);
|
||||
assert.ok(c.snapshot.state.players.every((p) => !cell(c.snapshot.state, p.position).lava));
|
||||
assert.ok(threatened(c.snapshot.state).includes("3,2"), "The next wave threatens their starting position");
|
||||
await c.continue();
|
||||
assert.equal(await c.play({ action: "plan", path: ["3,2", "4,2", WIN_DESTINATION] }), true, c.snapshot.error);
|
||||
assert.equal(await c.play({ action: "ready" }), true, c.snapshot.error);
|
||||
assert.equal(c.snapshot.state.phase, "reroll");
|
||||
assert.equal(await c.play({ action: "finishRerolls" }), true, c.snapshot.error);
|
||||
assert.equal(c.snapshot.state.phase, "equipment");
|
||||
assert.equal(await c.play({ action: "ready" }), true, c.snapshot.error);
|
||||
assert.equal(c.snapshot.state.outcome, "won");
|
||||
assert.ok(
|
||||
c.snapshot.state.players.every((p) => terrain(cell(c.snapshot.state, p.position).terrain).kind === "village")
|
||||
);
|
||||
assert.equal(c.snapshot.state.log.filter((e) => e.journey?.moved).length, 3);
|
||||
assert.equal(c.snapshot.state.log.filter((e) => e.animation?.kind === "eruption").length, 0);
|
||||
assert.equal(c.snapshot.completed, true);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ import { firstSteps, firstStepsState, lessonMove, DESTINATION } from "./first-st
|
|||
const only =
|
||||
(...actions: string[]) =>
|
||||
(_state: State, move: Move) =>
|
||||
actions.includes(move.action)
|
||||
? undefined
|
||||
: "Follow this step's highlighted action. Choose Retry step to try again.";
|
||||
actions.includes(move.action) ? undefined : "Follow this step's highlighted action. Use Replay step to try again.";
|
||||
|
||||
function setTerrain(state: State, id: string, type: number) {
|
||||
const target = cell(state, id);
|
||||
|
|
@ -167,7 +165,7 @@ export const terrainLesson: TutorialOptions<State, Move> = {
|
|||
{
|
||||
id: "first-roll",
|
||||
title: "Spend the first reroll",
|
||||
text: "Keep the four matching dice (1, 2, 2, 1). Select both 6s — the fifth and sixth dice — and reroll them together. This spends one reroll, leaving one more.",
|
||||
text: "Keep the four matching dice (1, 2, 2, 1). Select both 6s (dice 5 and 6) and reroll them together. This spends one reroll, leaving one more.",
|
||||
target: "dice",
|
||||
complete: (s) => s.players[0]!.rerolls === 1,
|
||||
validateMove: (_s, m) =>
|
||||
|
|
@ -278,4 +276,102 @@ export const lavaLesson: TutorialOptions<State, Move> = {
|
|||
},
|
||||
};
|
||||
|
||||
export const lessons = [firstSteps, equipmentLesson, terrainLesson, lavaLesson];
|
||||
export const WIN_DESTINATION = "4,1";
|
||||
export function winState() {
|
||||
let state = firstStepsState();
|
||||
state.round = 5;
|
||||
state.initOptions.autoMovement = true;
|
||||
state.initOptions.autoProgress = false;
|
||||
// Use the garden as one of this prepared map's five village tiles.
|
||||
cell(state, "4,0").terrain = 31;
|
||||
for (let wave = 0; wave < 4; wave++) {
|
||||
const next = threatened(state);
|
||||
for (const c of state.board) if (next.includes(c.id)) c.lava = true;
|
||||
}
|
||||
state.players.forEach((player, seat) => {
|
||||
player.position = "3,2";
|
||||
player.path = [player.position];
|
||||
player.dice.forEach((die) => {
|
||||
die.face = [6, 1, 5][seat]!;
|
||||
});
|
||||
});
|
||||
for (const [seat, path] of [
|
||||
[1, ["3,2", "4,2", "4,1", "4,0"]],
|
||||
[2, ["3,2", "4,2"]],
|
||||
] as const) {
|
||||
state = applyMove(state, { action: "plan", path: [...path] }, seat);
|
||||
state = applyMove(state, { action: "ready" }, seat);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
function winMove(state: State, move: Move) {
|
||||
let next = applyMove(state, move, 0);
|
||||
for (const seat of [1, 2]) {
|
||||
if (next.phase === "reroll" && !next.players[seat]!.ready) {
|
||||
next = applyMove(next, { action: "finishRerolls" }, seat);
|
||||
}
|
||||
if (state.phase === "equipment" && next.phase === "equipment" && !next.players[seat]!.ready) {
|
||||
next = applyMove(next, { action: "ready" }, seat);
|
||||
}
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
export const winLesson: TutorialOptions<State, Move> = {
|
||||
game: "fuji",
|
||||
id: "village",
|
||||
version: 1,
|
||||
initialState: winState,
|
||||
move: winMove,
|
||||
steps: [
|
||||
{
|
||||
id: "welcome",
|
||||
title: "One last journey",
|
||||
text: "The lava is close and the village is within reach. Mika has chosen Village garden and Ren has chosen Blossom square. Help all three explorers get to safety. Reaching the village alone does not win the game.",
|
||||
target: "board",
|
||||
},
|
||||
{
|
||||
id: "destination",
|
||||
title: "Choose Village street",
|
||||
text: "Choose the highlighted Village street, two spaces away. It counts 4s and 6s, so your six 6s are a strong match. Each explorer must choose a different destination.",
|
||||
target: `tile:${WIN_DESTINATION}`,
|
||||
complete: (s) => s.players[0]!.path.at(-1) === WIN_DESTINATION,
|
||||
validateMove: (_s, m) =>
|
||||
m.action === "plan" && Array.isArray(m.path) && m.path.length === 3 && m.path.at(-1) === WIN_DESTINATION
|
||||
? undefined
|
||||
: "Choose Village street via Blossom square.",
|
||||
},
|
||||
{
|
||||
id: "confirm",
|
||||
title: "Confirm your destination",
|
||||
text: "Mika and Ren are ready. Confirm your route to begin the dice phase.",
|
||||
target: "confirm",
|
||||
complete: (s) => s.phase === "reroll",
|
||||
validateMove: only("ready"),
|
||||
},
|
||||
{
|
||||
id: "keep",
|
||||
title: "Keep these strong dice",
|
||||
text: "All your dice count at Village street. Keep them and finish rerolling. Your teammates keep the dice that suit their own destinations.",
|
||||
target: "finish-rerolls",
|
||||
complete: (s) => s.phase === "equipment",
|
||||
validateMove: only("finishRerolls"),
|
||||
},
|
||||
{
|
||||
id: "escape",
|
||||
title: "Bring everyone home",
|
||||
text: "Choose Ready to reveal. The game compares the dice and moves everyone in order. Watch all three explorers enter the village.",
|
||||
target: "confirm",
|
||||
complete: (s) => s.outcome === "won",
|
||||
validateMove: only("ready"),
|
||||
},
|
||||
],
|
||||
completion: {
|
||||
title: "Everyone escaped!",
|
||||
text: "You, Mika and Ren all reached the village. The whole team wins immediately, before another eruption. That is the goal: bring everyone home together.",
|
||||
target: "board",
|
||||
},
|
||||
};
|
||||
|
||||
export const lessons = [firstSteps, equipmentLesson, terrainLesson, lavaLesson, winLesson];
|
||||
|
|
|
|||
|
|
@ -32,12 +32,23 @@
|
|||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
align-items: start;
|
||||
align-items: center;
|
||||
}
|
||||
.bgs-tutorial-resets {
|
||||
.bgs-tutorial-playback,
|
||||
.bgs-tutorial-help {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-left: auto;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
gap: 6px;
|
||||
}
|
||||
.bgs-tutorial-guide .bgs-tutorial-transport {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
flex: 0 0 36px;
|
||||
}
|
||||
.bgs-tutorial-guide button {
|
||||
min-height: 32px;
|
||||
|
|
|
|||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
|
|
@ -34,8 +34,8 @@ importers:
|
|||
packages/viewer:
|
||||
dependencies:
|
||||
'@boardgamers/protocol':
|
||||
specifier: 0.3.0
|
||||
version: 0.3.0
|
||||
specifier: 0.3.1
|
||||
version: 0.3.1
|
||||
fuji-engine:
|
||||
specifier: workspace:*
|
||||
version: link:../engine
|
||||
|
|
@ -61,8 +61,8 @@ importers:
|
|||
|
||||
packages:
|
||||
|
||||
'@boardgamers/protocol@0.3.0':
|
||||
resolution: {integrity: sha512-9XI2+XK5RPdDM709Vh+uqHchr1cxe0DrtxLSvIMhhyDFaM0EutCQAuJkySQvKmdXTHizHxag+mNu4eaKx5Affw==}
|
||||
'@boardgamers/protocol@0.3.1':
|
||||
resolution: {integrity: sha512-FF8OUEvAZ+BKjZZ3Ab8Dw7oQh6TJOKMNkmRHqoabeE4clSp8lMRnHGGEakZdi7DplDJpstnya2fgBk2hX82UrA==}
|
||||
|
||||
'@jridgewell/gen-mapping@0.3.13':
|
||||
resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}
|
||||
|
|
@ -631,7 +631,7 @@ packages:
|
|||
|
||||
snapshots:
|
||||
|
||||
'@boardgamers/protocol@0.3.0':
|
||||
'@boardgamers/protocol@0.3.1':
|
||||
dependencies:
|
||||
zod: 4.6.2
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
packages:
|
||||
- packages/*
|
||||
minimumReleaseAgeExclude:
|
||||
- "@boardgamers/protocol@0.2.2 || 0.3.0"
|
||||
- "@boardgamers/protocol@0.2.2 || 0.3.0 || 0.3.1"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ async function recordPresentation(page) {
|
|||
positions: Array.from(document.querySelectorAll(".traveler"), (el) => el.style.transform),
|
||||
lava: document.querySelectorAll(".location.lava").length,
|
||||
complete: document.querySelector(".bgs-tutorial-heading strong")?.textContent === "Chapter complete",
|
||||
celebrating: !!document.querySelector(".victory-petals"),
|
||||
};
|
||||
if (JSON.stringify(frame) !== JSON.stringify(frames.at(-1))) frames.push(frame);
|
||||
};
|
||||
|
|
@ -48,10 +49,13 @@ async function finishRound(page) {
|
|||
|
||||
const server = createServer(async (req, res) => {
|
||||
if (req.url === "/fuji-viewer.iife.js" || req.url === "/fuji-viewer.css") {
|
||||
res.setHeader("content-type", req.url.endsWith("css") ? "text/css" : "text/javascript");
|
||||
res.setHeader(
|
||||
"content-type",
|
||||
req.url.endsWith("css") ? "text/css; charset=utf-8" : "text/javascript; charset=utf-8"
|
||||
);
|
||||
res.end(await readFile(new URL(`../packages/viewer/dist${req.url}`, import.meta.url)));
|
||||
} else {
|
||||
res.setHeader("content-type", "text/html");
|
||||
res.setHeader("content-type", "text/html; charset=utf-8");
|
||||
res.end(
|
||||
`<!doctype html><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="stylesheet" href="/fuji-viewer.css"><div id="app"></div><script src="/fuji-viewer.iife.js"></script><script>fuji.launchTutorial('#app', {chapter:new URLSearchParams(location.search).get('chapter') || 'first-steps'});</script>`
|
||||
);
|
||||
|
|
@ -60,11 +64,12 @@ const server = createServer(async (req, res) => {
|
|||
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
||||
const url = `http://127.0.0.1:${server.address().port}`;
|
||||
const browser = await chromium.launch({ headless: true, executablePath: process.env.FUJI_CHROMIUM_EXECUTABLE });
|
||||
const chapterFilter = process.env.FUJI_TUTORIAL_CHAPTER;
|
||||
try {
|
||||
for (const viewport of [
|
||||
{ width: 1440, height: 1000 },
|
||||
{ width: 390, height: 844 },
|
||||
]) {
|
||||
].filter(() => !chapterFilter || chapterFilter === "first-steps")) {
|
||||
const context = await browser.newContext({ viewport, reducedMotion: "reduce" });
|
||||
const page = await context.newPage();
|
||||
const errors = [];
|
||||
|
|
@ -109,19 +114,21 @@ try {
|
|||
() => document.querySelector(".bgs-tutorial-heading strong")?.textContent === "Chapter complete"
|
||||
);
|
||||
assert.match(await guide.innerText(), /You reached Hilltop lookout/);
|
||||
assert.equal(await guide.getByRole("button", { name: "Continue", exact: true }).isVisible(), false);
|
||||
assert.equal(await guide.getByRole("button", { name: "Continue", exact: true }).isEnabled(), false);
|
||||
await page.reload();
|
||||
await page.waitForFunction(
|
||||
() => document.querySelector(".bgs-tutorial-heading strong")?.textContent === "Chapter complete"
|
||||
);
|
||||
await guide.getByRole("button", { name: "Restart chapter", exact: true }).click();
|
||||
await guide.getByRole("button", { name: "Back to start", exact: true }).click();
|
||||
await step(1);
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1));
|
||||
assert.deepEqual(errors, []);
|
||||
await context.close();
|
||||
}
|
||||
for (const width of [1440, 390]) {
|
||||
for (const chapter of ["equipment", "terrain-bonuses", "lava"]) {
|
||||
for (const chapter of ["equipment", "terrain-bonuses", "lava"].filter(
|
||||
(id) => !chapterFilter || chapterFilter === id
|
||||
)) {
|
||||
const page = await browser.newPage({ viewport: { width, height: 900 }, reducedMotion: "reduce" });
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
|
|
@ -198,7 +205,7 @@ try {
|
|||
assert.match(await page.locator('[data-tutorial="journal"]').innerText(), /Mika was caught by the lava/);
|
||||
}
|
||||
await guide.getByText("Chapter complete", { exact: true }).waitFor();
|
||||
assert.equal(await guide.getByRole("button", { name: "Continue", exact: true }).isVisible(), false);
|
||||
assert.equal(await guide.getByRole("button", { name: "Continue", exact: true }).isEnabled(), false);
|
||||
if (chapter === "terrain-bonuses") {
|
||||
assert.match(await page.locator('[data-tutorial="equipment:rope"]').innerText(), /Available now/);
|
||||
}
|
||||
|
|
@ -209,8 +216,84 @@ try {
|
|||
await page.close();
|
||||
}
|
||||
}
|
||||
for (const { width, reducedMotion } of [
|
||||
{ width: 1440, reducedMotion: "reduce" },
|
||||
{ width: 390, reducedMotion: "reduce" },
|
||||
{ width: 1440, reducedMotion: "no-preference" },
|
||||
{ width: 390, reducedMotion: "no-preference" },
|
||||
].filter(() => !chapterFilter || chapterFilter === "village")) {
|
||||
const page = await browser.newPage({ viewport: { width, height: 900 }, reducedMotion });
|
||||
await page.goto(`${url}/?chapter=village`);
|
||||
const guide = page.locator(".bgs-tutorial-guide");
|
||||
await guide.getByRole("button", { name: "Continue", exact: true }).click();
|
||||
await guide.getByText("2/5 · Choose Village street", { exact: true }).waitFor();
|
||||
await page.locator('[data-tutorial="tile:4,1"]').click();
|
||||
await guide.getByText("3/5 · Confirm your destination", { exact: true }).waitFor();
|
||||
const confirm = () => page.locator('[data-tutorial="confirm"]:visible').first().click();
|
||||
await confirm();
|
||||
await guide.getByText("4/5 · Keep these strong dice", { exact: true }).waitFor();
|
||||
await guide.getByRole("button", { name: "Previous step", exact: true }).click();
|
||||
await guide.getByText("3/5 · Confirm your destination", { exact: true }).waitFor();
|
||||
await page.reload();
|
||||
await guide.getByText("3/5 · Confirm your destination", { exact: true }).waitFor();
|
||||
await confirm();
|
||||
await guide.getByText("4/5 · Keep these strong dice", { exact: true }).waitFor();
|
||||
await page.locator('[data-tutorial="finish-rerolls"]:visible').first().click();
|
||||
await guide.getByText("5/5 · Bring everyone home", { exact: true }).waitFor();
|
||||
assert.equal(await page.locator(".victory-petals").count(), 0);
|
||||
await recordPresentation(page);
|
||||
await confirm();
|
||||
await guide.getByText("Chapter complete", { exact: true }).waitFor();
|
||||
if (reducedMotion === "no-preference") await page.locator(".victory-petals").waitFor();
|
||||
const frames = await page.evaluate(() => window.readTutorialFrames());
|
||||
for (const seat of [0, 1, 2]) {
|
||||
assert.notEqual(frames[0].positions[seat], frames.at(-1).positions[seat]);
|
||||
assert.ok(
|
||||
frames.some((f) => !f.complete && f.positions[seat] === frames.at(-1).positions[seat]),
|
||||
"Moves are shown before chapter completion"
|
||||
);
|
||||
}
|
||||
assert.equal(frames[0].lava, frames.at(-1).lava, "Victory needs no further lava wave");
|
||||
assert.match(await guide.innerText(), /whole team wins immediately/);
|
||||
const bounds = await guide
|
||||
.locator(".bgs-tutorial-playback button")
|
||||
.evaluateAll((buttons) => buttons.map((b) => b.getBoundingClientRect().top));
|
||||
assert.equal(new Set(bounds).size, 1, "Playback controls stay on one row");
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth + 1), false);
|
||||
if (reducedMotion === "no-preference") {
|
||||
await page.locator(".victory-petals").waitFor();
|
||||
assert.equal(await page.locator(".victory-petals .petal").count(), 36);
|
||||
assert.ok(
|
||||
frames.some((f) => f.celebrating),
|
||||
"The victory starts the petal effect"
|
||||
);
|
||||
assert.equal(await page.locator(".victory-petals").evaluate((el) => getComputedStyle(el).pointerEvents), "none");
|
||||
assert.ok(
|
||||
frames
|
||||
.filter((f) => f.celebrating)
|
||||
.every((f) => JSON.stringify(f.positions) === JSON.stringify(frames.at(-1).positions)),
|
||||
"Petals follow every explorer's movement"
|
||||
);
|
||||
await page.waitForTimeout(1600);
|
||||
await page.screenshot({ path: `/tmp/fuji-victory-petals-${width}.png` });
|
||||
await page.locator(".victory-petals").waitFor({ state: "detached", timeout: 7000 });
|
||||
} else {
|
||||
assert.equal(await page.locator(".victory-petals").count(), 0, "Respect reduced motion");
|
||||
}
|
||||
await page.screenshot({ path: `/tmp/fuji-village-${width}.png`, fullPage: true });
|
||||
await page.reload();
|
||||
await guide.getByText("Chapter complete", { exact: true }).waitFor();
|
||||
assert.equal(
|
||||
await page.locator(".victory-petals").count(),
|
||||
0,
|
||||
"Refreshing a finished game does not celebrate again"
|
||||
);
|
||||
await page.close();
|
||||
}
|
||||
console.log(
|
||||
"Fuji tutorials: all four chapters complete on desktop/mobile, with reload, equipment, lava and visible dice logs."
|
||||
chapterFilter
|
||||
? `Fuji tutorial ${chapterFilter}: desktop/mobile checks passed.`
|
||||
: "Fuji tutorials: all five chapters complete on desktop/mobile, with reload, equipment, lava and visible dice logs."
|
||||
);
|
||||
} finally {
|
||||
await browser.close();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue