From a18cde6cdacae35c029624a115f91562a90c451b Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Tue, 6 Oct 2026 21:54:04 +0200 Subject: [PATCH] Expand hands-on tutorials and allow cancelling government changes --- web-client/bgs-tutorial.json | 55 +- web-client/docs/tutorial-curriculum.md | 38 +- web-client/package-lock.json | 4 +- web-client/package.json | 2 +- .../scripts/build-tutorial-fixtures.mjs | 44 +- web-client/src/App.svelte | 3 +- web-client/src/DecisionPanel.svelte | 1 + web-client/src/decision-controls.test.ts | 15 + web-client/src/decision-controls.ts | 5 +- web-client/src/localization/da.json | 39 +- web-client/src/localization/de.json | 39 +- web-client/src/localization/el.json | 39 +- web-client/src/localization/en.json | 39 +- web-client/src/localization/fa.json | 39 +- web-client/src/localization/fr.json | 39 +- web-client/src/localization/hi.json | 39 +- web-client/src/localization/it.json | 39 +- web-client/src/localization/ko.json | 39 +- web-client/src/localization/nl.json | 39 +- web-client/src/localization/pl.json | 39 +- web-client/src/localization/pt-BR.json | 39 +- web-client/src/localization/ro.json | 39 +- web-client/src/localization/ru.json | 39 +- web-client/src/localization/vi.json | 39 +- web-client/src/localization/zh-TW.json | 39 +- web-client/src/tutorial.test.ts | 25 + web-client/src/tutorial/lessons.ts | 151 ++-- ...{platform-tools.json => action-cards.json} | 575 +----------- .../src/tutorial/positions/cards-leaders.json | 4 +- .../tutorial/positions/combat-barbarians.json | 840 ++++++++++++++++++ .../src/tutorial/positions/pirates.json | 826 +++++++++++++++++ 31 files changed, 2527 insertions(+), 685 deletions(-) rename web-client/src/tutorial/positions/{platform-tools.json => action-cards.json} (56%) create mode 100644 web-client/src/tutorial/positions/combat-barbarians.json create mode 100644 web-client/src/tutorial/positions/pirates.json diff --git a/web-client/bgs-tutorial.json b/web-client/bgs-tutorial.json index 65a423db..e1340db4 100644 --- a/web-client/bgs-tutorial.json +++ b/web-client/bgs-tutorial.json @@ -13,102 +13,111 @@ { "id": "interaction", "title": "Interaction", - "description": "Resolve cultural influence and incidents one decision at a time." + "description": "Resolve cultural influence, incidents and battles on land and at sea." }, { "id": "mastery", "title": "Mastery", "description": "Understand leaders, wonders and objective timing." - }, - { - "id": "platform", - "title": "Platform tools", - "description": "Read the journal, review actions and understand undo." } ], "chapters": [ { "id": "first-turn", "title": "Your first turn", - "description": "Learn the three-action turn through collection and research.", "section": "basics", + "description": "Learn the three-action turn through collection and research.", "version": 1 }, { "id": "city-economy", "title": "A productive city", - "description": "Understand happy-city capacity, terrain and storage.", "section": "basics", + "description": "Understand happy-city capacity, terrain and storage.", "version": 1 }, { "id": "activation-happiness", "title": "Activation and happiness", - "description": "Improve multiple cities in one action without activating them.", "section": "basics", + "description": "Improve multiple cities in one action without activating them.", "version": 1 }, { "id": "research-paths", "title": "Research with a plan", - "description": "Follow prerequisites and discover advances that become free.", "section": "basics", + "description": "Follow prerequisites and discover advances that become free.", "version": 1 }, { "id": "movement-founding", "title": "Move, explore, found", - "description": "Separate movement groups from actions and founding.", "section": "expansion", + "description": "Separate movement groups from actions and founding.", "version": 2 }, { "id": "sea-transport", "title": "Ships and passengers", - "description": "Board, sail and land with the right movement timing.", "section": "expansion", + "description": "Board, sail and land with the right movement timing.", "version": 5 }, { "id": "cultural-influence", "title": "Cultural influence", - "description": "Pay for range, roll, then decide whether to boost the result.", "section": "interaction", + "description": "Pay for range, roll, then decide whether to boost the result.", "version": 1 }, { "id": "incidents-hostiles", "title": "Incidents and hostile units", - "description": "Read affected cities and resolve protection choices.", "section": "interaction", + "description": "Read affected cities and resolve protection choices.", + "version": 1 + }, + { + "id": "combat-barbarians", + "title": "Combat and barbarians", + "section": "interaction", + "description": "Attack a barbarian city, play a tactic and recover the captured city.", + "version": 1 + }, + { + "id": "pirates", + "title": "Pirates and sea control", + "section": "interaction", + "description": "Clear a pirate ship, choose your reward and collect from the freed sea.", "version": 1 }, { "id": "cards-leaders", - "title": "Cards, leaders and free actions", - "description": "Recruit a leader and distinguish payments from action costs.", + "title": "Civilization advances and leaders", "section": "mastery", - "version": 1 + "description": "Unlock a Roman advance and recruit one of Rome’s leaders.", + "version": 2 }, { "id": "wonders-ownership", "title": "Wonders and ownership", - "description": "Use Great Lighthouse and inspect builder versus owner points.", "section": "mastery", + "description": "Use Great Lighthouse and inspect builder versus owner points.", "version": 1 }, { "id": "objectives-ages", "title": "Objectives and the end of an age", - "description": "Meet the exact objective condition and distinguish claim timing.", "section": "mastery", + "description": "Meet the exact objective condition and distinguish claim timing.", "version": 1 }, { - "id": "platform-tools", - "title": "Read, review and recover", - "description": "Use rule references and understand the boundary of undo.", - "section": "platform", + "id": "action-cards", + "title": "Play an action card", + "section": "mastery", + "description": "Use a civil effect, then carry out the action it modifies.", "version": 1 } ] diff --git a/web-client/docs/tutorial-curriculum.md b/web-client/docs/tutorial-curriculum.md index 8b52f50a..37215fae 100644 --- a/web-client/docs/tutorial-curriculum.md +++ b/web-client/docs/tutorial-curriculum.md @@ -88,15 +88,15 @@ Metadata remains in English for translation through BGS admin. Tutorial prose be **Check:** Use the actual incident's target list; do not imply all incidents select one city. Protection must use the real Myths rules and payment. Empty incident phases should not appear as substantive replay actions. -### 9. Cards, leaders and free actions (`cards-leaders`, mastery, 7 minutes) +### 9. Civilization advances and leaders (`cards-leaders`, mastery, 7 minutes) -**Problem:** “Free action” is read as “free payment”; draft, recruit and card play are conflated. +**Problem:** Players miss civilization advances unlocked by normal research and the distinction between recruiting a leader and activating an ability. -**Position:** Great Prophet available with a legal Temple construction, one recruitable leader and a Shogunate example in a separate checkpoint. +**Position:** Rome knows Tactics, Writing and Math, and can research Engineering and recruit Caesar. -**Steps:** Read Great Prophet's conditions and payment; build without spending a normal action, while paying the listed cost; inspect leader recruitment and movement requirements; distinguish Shogunate card drafting from playing a card and its separate allowance. Show Draft as military conscription of one unit, not civilization selection. +**Steps:** Research Engineering; inspect the automatically unlocked Aqueduct; recruit Caesar through the normal Recruit controls; inspect the civilization overview for leader abilities. -**Check:** Free actions still pay their specified resource costs. Ability counters reset at the correct turn boundary. Do not use a formerly broken interaction as a tutorial rule. +**Check:** Research and recruitment each spend one action. Aqueduct is owned after Engineering and Caesar is present after recruitment. Action-card play has its own interactive chapter below. ### 10. Wonders and ownership (`wonders-ownership`, mastery, 7 minutes) @@ -118,27 +118,17 @@ Metadata remains in English for translation through BGS admin. Tutorial prose be **Check:** Match objective IDs and triggers, not translated name text. A battle example must satisfy every printed condition. Show completion progress rather than treating any victory as sufficient. -### 12. Read, review and recover (`platform-tools`, reference, 5 minutes) - -**Problem:** Undo, visual replay and analysis are confused; useful rules links and preferences are hidden. - -**Position:** A short existing example history with one information reveal and two harmless actions, loaded as an isolated tutorial fixture. - -**Steps:** Click an advance or card in the journal; locate a coordinate on the map; step through the last turn's actions; observe that empty phase changes are skipped; inspect the undo boundary at an information reveal; enter analysis and return to the live position. Visit available-actions filtering, colorblind display and map-orientation preferences in platform settings. - -**Check:** Tutorial analysis never writes to a live game. The replay example uses the current action log format. A failed replay must leave the original position intact. Explain that “available actions only” filters choices; it does not execute or skip decisions. - ## Delivery and acceptance -Implement chapters in this order: 1–5 and 7 first, then 6 and 8–12. These address the most frequent onboarding questions without requiring every optional rule on day one. Keep each chapter around five to eight minutes and offer a skip-to-reference route for experienced players. +The implemented chapters below supersede the original ordering above. These address the most frequent onboarding questions without requiring every optional rule on day one. Keep each chapter around five to eight minutes and offer a skip-to-reference route for experienced players. Each chapter needs a current engine-generated fixture, deterministic scripted opponent responses, constrained real actions, one failure-path test, a complete successful walkthrough, a restart/restore test and screenshots in English plus at least one non-Latin locale. Save action history rather than trusting serialized tutorial progress. Keep stable chapter IDs, and increment the chapter version when an engine/rule change invalidates stored history. -One feedback item remains open: selecting a hex sometimes opens movement and sometimes city details. That is a UI consistency problem. Resolve it in the viewer; a tutorial should explain a consistent interaction, not teach players to anticipate a surprising one. +Hex clicks now inspect the tile; unit clicks open movement. Tutorials use those consistent controls. ## Implemented release scope -The release registers all 12 independent chapters in five sections: basics, expansion, interaction, mastery and platform tools. Each chapter has a small production-engine position, constrained legal moves, explanations and/or checks, plus validated save, restart and failure behavior. The longer scenarios above remain curriculum ideas; they do not all occur in the initial chapters. +The release registers 14 independent chapters in four sections: basics, expansion, interaction and mastery. Each chapter has a small production-engine position, constrained legal moves, explanations and/or checks, plus validated save, restart and failure behavior. The longer scenarios above remain curriculum ideas; they do not all occur in the initial chapters. | Chapter | Interactive exercise in this release | | ------------------------------ | ----------------------------------------------------------------------------------------------------------------- | @@ -146,13 +136,17 @@ The release registers all 12 independent chapters in five sections: basics, expa | A productive city | Collect from a happy size-2 city; check capacity and overflow. | | Activation and happiness | Improve two cities together, then collect and compare activation counts. | | Research with a plan | Research Math and claim Engineering without a resource payment. | -| Move, explore, found | Move a settler, finish movement, found a city, then explore and orient a region. | +| Move, explore, found | Move both settlers in one Move action, explore and orient a region, then found the city. | | Ships and passengers | Board, sail, then disembark to explore a new region in the next action. | | Cultural influence | Select a Temple, pay extra range, see the roll, pay the boost, and compare building and city ownership. | | Incidents and hostile factions | Trigger Heavy Flood, protect with Myths, and resolve the scripted opponent's city choice; inspect hostile guides. | -| Cards and leaders | Recruit Caesar and distinguish a free action from a free payment through a check. | +| Civilization advances and leaders | Research Engineering to unlock Rome’s Aqueduct, recruit Caesar, and inspect civilization and leader abilities. | | Wonders and ownership | Activate a Lighthouse city and accept its optional ship; check Pyramid builder scoring. | | Objectives and ages | Recruit twice and claim Draft; check when final-age rewards stop. | -| Platform tools | Undo a harmless research action; distinguish analysis and explain the platform preferences. | +| Combat and barbarians | Attack with three infantry, play Peltasts, read the roll, capture the city and improve its mood. Fortress-only defense is explained using official rulebook page 23. | +| Pirates and sea control | Attack pirates with ships, choose the token reward, then collect from the freed sea tile. | +| Play an action card | Play Production Focus and click the same forest three times to collect three wood. | -Tutorial game steps use the normal board controls. The sidebar provides a control path and highlights the relevant controls; only quiz answers have sidebar buttons. Legal collection choices, research payments and city selection order are accepted and validated by the engine. Unrelated actions are rejected without changing the position. The 12 walkthrough tests also restore saved history and restart, and semantic assertions verify the key rules effects. +Tutorial game steps use the normal board controls. The sidebar provides a control path and highlights the relevant controls; only quiz answers have sidebar buttons. Legal collection choices, research payments and city selection order are accepted and validated by the engine. Unrelated actions are rejected without changing the position. The 14 walkthrough tests also restore saved history and restart, and semantic assertions verify the key rules effects. + +The final Platform tools section has been removed. The tutorial now has four sections and fourteen chapters. The new lessons use production engine fixtures with fixed combat rolls; rewards, casualties, action counts and city ownership are checked by walkthrough tests. Lesson text is translated contextually into all sixteen supported locales. diff --git a/web-client/package-lock.json b/web-client/package-lock.json index dc69147a..f8020774 100644 --- a/web-client/package-lock.json +++ b/web-client/package-lock.json @@ -1,12 +1,12 @@ { "name": "@boardgamers/clash-web-client", - "version": "0.1.17", + "version": "0.1.18", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@boardgamers/clash-web-client", - "version": "0.1.17", + "version": "0.1.18", "dependencies": { "@boardgamers/protocol": "0.9.0", "lucide-svelte": "^0.577.0", diff --git a/web-client/package.json b/web-client/package.json index 372fd99a..37c6e355 100644 --- a/web-client/package.json +++ b/web-client/package.json @@ -1,6 +1,6 @@ { "name": "@boardgamers/clash-web-client", - "version": "0.1.17", + "version": "0.1.18", "private": true, "type": "module", "scripts": { diff --git a/web-client/scripts/build-tutorial-fixtures.mjs b/web-client/scripts/build-tutorial-fixtures.mjs index cb36a99e..c50445e9 100644 --- a/web-client/scripts/build-tutorial-fixtures.mjs +++ b/web-client/scripts/build-tutorial-fixtures.mjs @@ -53,7 +53,9 @@ for (const id of [ 'cards-leaders', 'wonders-ownership', 'objectives-ages', - 'platform-tools', + 'combat-barbarians', + 'pirates', + 'action-cards', ]) { let g = structuredClone(base), p = g.players[0]; @@ -110,7 +112,7 @@ for (const id of [ g.players[0].advances.push('Myths'); } if (id === 'cards-leaders') { - p.advances.push('Tactics'); + p.advances.push('Tactics', 'Writing', 'Math'); p.available_leaders = ['Caesar', 'Augustus', 'Sulla']; } if (id === 'wonders-ownership') { @@ -122,14 +124,34 @@ for (const id of [ if (id === 'objectives-ages') { g = await fixture('objective_cards/instant/draft'); } - if (id === 'platform-tools') { - g = JSON.parse( - engine.tryMove( - JSON.stringify(g), - JSON.stringify({ Playing: { Advance: { advance: 'Storage', payment: { food: 2 } } } }), - 0, - ), - ); + if (id === 'combat-barbarians') { + p.advances.push('Tactics'); + p.action_cards = [20]; + p.units = [0, 1, 2].map((id) => ({id, position: 'D2', unit_type: 'Infantry'})); + p.next_unit_id = 3; + const barbarians = g.players.find((p) => p.civilization === 'Barbarians'); + barbarians.cities = [{position: 'C2', mood_state: 'Neutral'}]; + barbarians.units = [{id: 0, position: 'C2', unit_type: 'Infantry'}]; + barbarians.next_unit_id = 1; + // A fixed teaching roll: Peltasts succeeds, the army wins without casualties. + g.dice_roll_outcomes = [11, 9, 0, 0, 11]; + } + if (id === 'pirates') { + p.advances.push('Fishing', 'Tactics'); + p.action_cards = []; + p.resources.food = 0; + p.units = [0, 1].map((id) => ({id, position: 'D1', unit_type: 'Ship'})); + p.next_unit_id = 2; + g.map.tiles.find(([position]) => position === 'C2')[1] = 'Water'; + const pirates = g.players.find((p) => p.civilization === 'Pirates'); + pirates.units = [{id: 0, position: 'C2', unit_type: 'Ship'}]; + pirates.next_unit_id = 1; + g.dice_roll_outcomes = [0, 11, 11]; + } + if (id === 'action-cards') { + p.action_cards = [20]; + p.cities[0].city_pieces = {academy: 0}; + p.resources.wood = 0; } // Older test fixtures serialize token fields, but only goods have storage limits. for (const player of g.players) { @@ -139,4 +161,4 @@ for (const id of [ engine.webView(engine.stripSecret(JSON.stringify(g), 0), 0); await fs.writeFile(new URL(`${id}.json`, directory), JSON.stringify(g, null, 2) + '\n'); } -console.log('Wrote 12 validated tutorial positions'); +console.log('Wrote validated tutorial positions'); diff --git a/web-client/src/App.svelte b/web-client/src/App.svelte index 7af4ff37..20a6300a 100644 --- a/web-client/src/App.svelte +++ b/web-client/src/App.svelte @@ -705,6 +705,7 @@ {#if $session.seat !== undefined}