Add interactive CoC tutorials and lazy-loaded BGS locales

This commit is contained in:
coyotte508 2026-10-06 19:51:17 +02:00
commit 36d7fa6339
66 changed files with 84539 additions and 140 deletions

View file

@ -25,4 +25,4 @@ jobs:
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: clash-viewer
path: web-client/dist/viewer.js
path: web-client/dist/

View file

@ -6,15 +6,17 @@ from fontTools import subset
from fontTools.ttLib import TTFont
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--catalog-dir', default='client/js/src/localization')
parser.add_argument('--output-dir', default='client/assets/localization')
parser.add_argument('--cjk-font', default='/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc')
parser.add_argument('--devanagari-font', default='/usr/share/fonts/truetype/noto/NotoSansDevanagari-Regular.ttf')
parser.add_argument('--arabic-font', default='/usr/share/fonts/truetype/noto/NotoSansArabic-Regular.ttf')
args = parser.parse_args()
root = Path(__file__).resolve().parent.parent
output = root / 'client/assets/localization'
output = root / args.output_dir
output.mkdir(parents=True, exist_ok=True)
for locale, name, index in [('ko', 'Korean', 1), ('zh-TW', 'Chinese', 3), ('hi', 'Devanagari', None), ('fa', 'Arabic', None)]:
catalog = json.loads((root / f'client/js/src/localization/{locale}.json').read_text())
catalog = json.loads((root / args.catalog_dir / f'{locale}.json').read_text())
text = ''.join(catalog.values()) + ''.join(chr(i) for i in range(32, 256))
font = TTFont(args.cjk_font, fontNumber=index) if index is not None else TTFont(args.arabic_font if locale == "fa" else args.devanagari_font)
processor = subset.Subsetter(options=subset.Options())

View file

@ -61,7 +61,7 @@ cargo test -p server --lib web_view
After building, `http://127.0.0.1:8643/?built` loads the production IIFE bundle inside the preview host.
`dist/viewer.js` contains the interface and styles. Upload `dist/server_bg.wasm` beside it for the Rust bridge. It exports `window.clash3d.launch(selector)` and uses string state/move payloads, matching the existing engine. Configure `topLevelVariable: "clash3d"`, `fullScreen: true`, `chat: true`, and `replayable: true`. No extra runtime scripts or stylesheets are needed. Fonts currently load from Google Fonts; system fonts remain available if blocked.
`dist/viewer.js` contains the interface and styles. Upload `dist/server_bg.wasm` beside it for the Rust bridge. It exports `window.clash3d.launch(selector)` and uses string state/move payloads, matching the existing engine. Publish the complete `dist/` asset tree, including separate locale catalogs, tutorial positions and script fonts. Configure `topLevelVariable: "clash3d"`, `fullScreen: true`, `chat: true`, and `replayable: true`. No extra runtime scripts or stylesheets are needed. Latin fonts load from Google Fonts, with system fallbacks. Hindi, Persian, Korean and Traditional Chinese use bundled Noto subsets, downloaded only when their script is used.
## Publish to BGS
@ -76,7 +76,7 @@ The script uploads the viewer, verifies the hosted bytes, then updates the versi
## Remaining playtest work
Automated scenarios cover a complete six-age sequence, mixed rewards, government changes, combat casualties/tactics, wonder construction, action cards, influence, civilization abilities, army/fleet movement and transport, leaders/replacements, and free/multi-city actions. This is playtest coverage, not an exhaustive check of every civilization/card interaction. Ordinary research, construction and recruitment still choose the engine's first valid resource payment; explicit payment requests allow resource adjustments. Models for buildings and units are preliminary. Replay shows the most recent 192 recorded public board positions. Existing saves start recording on their next action; earlier positions are unavailable. Catch-up opens unseen opponent actions with Back/Next, 2.5-second autoplay (longer for battles), a saved per-player autoplay preference, and Skip. The Last turn shortcut opens the latest opponent turn paused; both modes stay open at completion and replay only their selected range. Captions and map highlights use public board changes, and manual steps animate unless reduced motion is enabled. Battles show recorded dice, hits, cancelled hits and casualties in a compact panel, with a pulse on the battlefield. Battle results stay visible during manual stepping, and autoplay allows 4.4 seconds per battle update before continuing. Analysis branches start from the current position, resample hidden state independently, and preserve supported public pending choices; private continuations, remembered Spy information and refilled card piles remain unsupported. The interface text is currently English; existing game translations need to be wired into the new presentation layer. Advanced accessibility preferences still need a separate pass.
Automated scenarios cover a complete six-age sequence, mixed rewards, government changes, combat casualties/tactics, wonder construction, action cards, influence, civilization abilities, army/fleet movement and transport, leaders/replacements, and free/multi-city actions. This is playtest coverage, not an exhaustive check of every civilization/card interaction. Ordinary research, construction and recruitment still choose the engine's first valid resource payment; explicit payment requests allow resource adjustments. Models for buildings and units are preliminary. Replay shows the most recent 192 recorded public board positions. Existing saves start recording on their next action; earlier positions are unavailable. Catch-up opens unseen opponent actions with Back/Next, 2.5-second autoplay (longer for battles), a saved per-player autoplay preference, and Skip. The Last turn shortcut opens the latest opponent turn paused; both modes stay open at completion and replay only their selected range. Captions and map highlights use public board changes, and manual steps animate unless reduced motion is enabled. Battles show recorded dice, hits, cancelled hits and casualties in a compact panel, with a pulse on the battlefield. Battle results stay visible during manual stepping, and autoplay allows 4.4 seconds per battle update before continuing. Analysis branches start from the current position, resample hidden state independently, and preserve supported public pending choices; private continuations, remembered Spy information and refilled card piles remain unsupported. The viewer selects its language from BGS preferences and loads only that locale’s catalog. English requires no catalog download. Rule text, references and resource icons use the same engine IDs across languages. Advanced accessibility preferences still need a separate pass.
Before public release: play through unusual civilization/card combinations, verify against an actual BGS staging game (including reconnects, moderation, translation, and read-state persistence), and test larger multiplayer boards on mobile hardware.
@ -93,3 +93,13 @@ Viewer releases: see [uploading the complete viewer build](docs/viewer-publishin
Game length defaults to six ages. Epic games use ten ages; existing saves without a length option retain six. The viewer age track follows the saved option. Publish an engine that supports the length option alongside the setup metadata.
The opt-in `skipRazeCity` player setting is saved in the game by the engine. End-of-age processing keeps that player's cities automatically, including when another player advances the game while they are offline. Analysis branches clear automation settings. The viewer migrates an existing enabled account preference the first time the player opens each game after upgrading (an explicit per-game opt-out takes priority). The decision checkbox saves the setting and explicitly answers the current choice after acknowledgement; loading saved preferences or settings never submits a move.
## Tutorials and localization
Twelve independent interactive chapters are grouped into Basics, Expansion, Interaction, Mastery and Platform tools. `launchTutorial(selector, {chapter, locale, onProgress, nextChapter})` uses the BGS tutorial protocol. Each lesson runs the production WASM engine on an isolated starting position; moves never reach a live game. Progress stores validated action history locally, and reconstructs it on restore. Rejected moves and engine failures leave the prior lesson state intact.
Open `/tutorial-preview.html?chapter=cultural-influence&locale=fr` for a chapter preview; add `&built` to test the production bundle. `?locale=fr` also sets the language of the normal development preview. Chapter metadata is declared in `bgs-tutorial.json`; publishing preserves admin edits while chapter IDs and versions are unchanged. Metadata translation is managed separately through BGS admin.
The curriculum and its anonymized evidence are in [docs/tutorial-curriculum.md](docs/tutorial-curriculum.md). Context for translators is in [docs/localization-context.md](docs/localization-context.md). Catalogs are separate files under `src/localization/`, and the URL manifest does not embed their contents in `viewer.js`. `npm run test:locales` checks all supported locale keys and placeholders. `npm run localization:extract` adds source strings; it does not translate them. In-game translations must be written with rule/UI context rather than sent to a generic translation endpoint.
`npm run tutorial:fixtures` regenerates engine-validated starting positions; review the resulting fixtures and run the complete chapter walkthrough tests before publishing. To regenerate Noto font subsets after translation edits, run `python scripts/build-localization-fonts.py --catalog-dir web-client/src/localization --output-dir web-client/src/localization/fonts` from the repository root with `fonttools[woff]` and Noto fonts installed.

View file

@ -0,0 +1,115 @@
{
"sections": [
{
"id": "basics",
"title": "The basics",
"description": "Take your first turn, improve your cities and plan research."
},
{
"id": "expansion",
"title": "Expansion",
"description": "Move groups, explore regions and transport units by sea."
},
{
"id": "interaction",
"title": "Interaction",
"description": "Resolve cultural influence and incidents one decision at a time."
},
{
"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",
"version": 1
},
{
"id": "city-economy",
"title": "A productive city",
"description": "Understand happy-city capacity, terrain and storage.",
"section": "basics",
"version": 1
},
{
"id": "activation-happiness",
"title": "Activation and happiness",
"description": "Improve multiple cities in one action without activating them.",
"section": "basics",
"version": 1
},
{
"id": "research-paths",
"title": "Research with a plan",
"description": "Follow prerequisites and discover advances that become free.",
"section": "basics",
"version": 1
},
{
"id": "movement-founding",
"title": "Move, explore, found",
"description": "Separate movement groups from actions and founding.",
"section": "expansion",
"version": 1
},
{
"id": "sea-transport",
"title": "Ships and passengers",
"description": "Board, sail and land with the right movement timing.",
"section": "expansion",
"version": 1
},
{
"id": "cultural-influence",
"title": "Cultural influence",
"description": "Pay for range, roll, then decide whether to boost the result.",
"section": "interaction",
"version": 1
},
{
"id": "incidents-hostiles",
"title": "Incidents and hostile units",
"description": "Read affected cities and resolve protection choices.",
"section": "interaction",
"version": 1
},
{
"id": "cards-leaders",
"title": "Cards, leaders and free actions",
"description": "Recruit a leader and distinguish payments from action costs.",
"section": "mastery",
"version": 1
},
{
"id": "wonders-ownership",
"title": "Wonders and ownership",
"description": "Use Great Lighthouse and inspect builder versus owner points.",
"section": "mastery",
"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",
"version": 1
},
{
"id": "platform-tools",
"title": "Read, review and recover",
"description": "Use rule references and understand the boundary of undo.",
"section": "platform",
"version": 1
}
]
}

View file

@ -0,0 +1,20 @@
# CoC localization context
This is the current Svelte/3D viewer for Clash of Cultures: Monumental Edition. The implementation in `server/src` and presentation in `web-client/src` are authoritative for what each UI string means. `client/js/src/localization` contains older translations to reuse, rather than translate the same rule again.
Translate public interface and rules text yourself with context; do not use BGS's translation endpoint or another translation service. Preserve `{p0}`, `{p1}`, etc., numbers, numeric ranges, rules conditions, and action/resource distinctions. Keep internal command IDs, CSS, URLs and developer identifiers unchanged. Preserve player-entered names, messages and saved state; only presentation changes. Proper historical leader names may use conventional spellings. Prefer existing game terminology in each locale, correcting misleading terms where necessary.
- Advance: a researched technology; “advance” is not moving a unit forward. Research normally spends food; particular abilities allow other payments. Civilization advances are that civilization's special advances. Government advances and prerequisites are separate from research groups.
- Mood tokens and culture tokens are tokens, distinct from ordinary resources (food, wood, ore, ideas, gold). “Resources” in a rule may exclude tokens. Gold substitution must not imply that it can replace mood/culture indiscriminately.
- City size counts its city center and buildings. Collection capacity depends on size and mood. A happy city collects one extra; angry cities have restrictions. A city activation is a game mechanic, distinct from selecting a city in the interface. Increasing happiness is an action that can affect several cities and does not activate them. Razing is destroying an eligible city at the end of an age; skipping raze is not abandoning a turn.
- Draft is military conscription, not choosing cards at setup. Civilization draft is choosing a civilization; action-card drafting is its own ability. Shogunate's card drafting and card-play allowances are separate.
- Cultural influence changes a building's ownership, not the city's owner. Keep the initial fee, range-extension payment, success-roll shortfall, optional culture boost, reroll and failed attempt distinct. Building color identifies its owner.
- Movement groups: a movement action can move up to three groups; terrain and Tactics impose limits. Founding a city needs a separate action and an eligible settler, and does not become free merely because a movement group is selected. Embarked units travel with their ship and do not spend an independent group to follow it.
- Exploration reveals one region, comprising four hexes. Region is a map object, distinct from one tile. Barren and exhausted are different terrain states.
- Pirates are naval enemies with flags; barbarians use horned helmets. Spawn, reinforcement and movement have separate eligibility rules. Guides preview legal spaces; they are not actions that create pieces.
- Objectives are scoring goals on objective cards, including battle conditions. Wonders have separate points/effects for building versus owning. Great Pyramid gives its builder 5.1 points and its owner 0. A free action can still require resources; a free advance may still require the action and prerequisites. Great Lighthouse rewards activating its city with an optional ship; it does not grant another city activation.
- Replay/“Since your last turn” is a visual recap. Undo is constrained by information reveals. Replay does not mutate the live game. Analysis is an independent sandbox.
English source keys include templates for dynamic quantities and historical source extraction. Many technical literals were already present in the older source catalogue; do not translate identifiers as if they were prose. Look up ambiguous short labels at their call sites before deciding.
BGS locales: en, de, fr, pl, ro, el, hi, ru, da, pt-BR, ko, zh-TW, vi, it, nl, fa. Tutorial chapter metadata on BGS will be translated separately by the user; in-game tutorial prose is part of the viewer catalogue.

View file

@ -0,0 +1,158 @@
# Clash of Cultures tutorial curriculum
This proposal comes from a complete read of the available CoC game chats and player feedback on 6 October 2026: 12 games, 203 chat records (164 human text messages), 47 private feedback threads and 93 replies. There were no matching public discussions or public feedback records. Private messages and player names are deliberately absent from this document.
The recurring problem is knowing _which step happens next_, not remembering every rule. Each chapter should start from a small deterministic position, ask the learner to perform a real action, show its consequence, and finish with one short decision. Use the production engine to validate actions. An invalid or unrelated action should leave the position unchanged and explain the required step. Chapters must be independent, resumable and restartable through the BGS tutorial protocol.
Metadata remains in English for translation through BGS admin. Tutorial prose belongs in the viewer's per-language catalogs, with the same glossary as the game UI. Do not register unfinished chapters in gameinfo.
## Suggested order
### 1. Your first turn (`first-turn`, basics, 5 minutes)
**Problem:** Players miss whose turn it is, the three-action limit, or confuse choosing a second movement group with taking another action.
**Position:** Two civilizations; learner is active with a size-1 neutral city, an adjacent settler and enough resources for one advance. No imminent incident.
**Steps:** Identify the active civilization and remaining actions; collect once; inspect the resulting activation marker; research one advance; end the turn with one action left. Explain that spending all three actions is optional, and that passing commits the turn.
**Check:** Selecting an opponent's piece does not grant an action. A move belonging to the opponent must be refused. The action count must fall once per actual action, not once per dialog click.
### 2. A productive city (`city-economy`, basics, 7 minutes)
**Problem:** Happy collection, capacity, terrain yields and storage overflow cause repeated questions.
**Position:** Happy size-2 city beside fertile land, forest and mountains; two food already stored, without Storage. Include one collection option with a resource substitution.
**Steps:** Inspect capacity (3); choose three legal yields; change one allocation without losing the others; notice the food storage warning; select a useful non-overflowing collection; compare the result with a neutral city. Inspect Taxes as an alternative action, rather than an extra resource from collection.
**Check:** Capacity limits and tile yields come from the engine. Ball Courts changes must preserve valid allocation choices. The lesson must not rely on silently discarding overflow.
### 3. Activation and happiness (`activation-happiness`, basics, 6 minutes)
**Problem:** City activation and happiness are mistaken for the same mechanic; players miss the global multi-city happiness action.
**Position:** Two size-1 cities, one neutral and already activated, one angry and unused; enough mood tokens to improve both.
**Steps:** Predict the first city's mood after a second activation; increase happiness in both cities in one action; verify happiness did not activate either city; collect from the city previously angry; inspect the new mood and activation state. Explain the once-while-angry restriction and why an angry city cannot construct.
**Check:** Improving two cities spends one action, with the cost calculated for each selected city and each mood step. No activation marker changes during happiness.
### 4. Research with a plan (`research-paths`, basics, 7 minutes)
**Problem:** Research payments are confused with an ideas-only cost; players miss free advances and civilization prerequisites.
**Position:** Learner can afford research with food and ideas, is near Math, and has an available civilization advance. Keep Free Education and Priesthood for an optional final panel.
**Steps:** Open the research tree; pay with food and ideas; follow the prerequisites to Math; inspect the “Free with Math” hint on Engineering/Roads; claim the resulting free advance; inspect civilization-specific research and the other civilizations below the regular tree. Identify the remaining event markers.
**Check:** The lesson reads current engine costs and dependencies. It must distinguish researching for no resource cost from spending no action. Explain Free Education's prerequisite separately from normal research payment, and Priesthood's once-per-turn use.
### 5. Move, explore, found (`movement-founding`, expansion, 8 minutes)
**Problem:** Founding is confused with finishing a movement group; exploration is assumed to reveal a single hex.
**Position:** Two settler groups, safe adjacent land and an unexplored region; army units are visible but Tactics is absent.
**Steps:** Start Move; move the first group; move a second group within the same action; finish movement explicitly; found a city using a separate action; explore a region and choose its orientation; inspect all four revealed hexes. Compare forest and mountain movement restrictions.
**Check:** Movement spends one action for up to three groups. A unit cannot join two groups within that action. Tactics restrictions and founding legality use the real engine. Failed destinations do not change the state.
### 6. Ships and passengers (`sea-transport`, expansion, 7 minutes)
**Problem:** Boarding, sailing and landing allowances are difficult to infer from the UI.
**Position:** Port, one ship and two land units on adjacent land; a second ship begins with passengers aboard.
**Steps:** Inspect two-passenger capacity; board and sail in one Move action; attempt landing and explain why it requires another action for those newly boarded units; then compare a ship whose units were aboard before the action, which can sail and land in one action. Show the sea destination choice after exploration.
**Check:** Demonstrate both timing cases with actual legal moves. Passenger identity remains attached to the carrier, and rejected landings are atomic.
### 7. Cultural influence, one decision at a time (`cultural-influence`, interaction, 8 minutes)
**Problem:** Range, payment, the roll and an optional boost look like unrelated dialogs; building color is mistaken for city ownership.
**Position:** A size-2 source city, an enemy building three spaces away, sufficient culture tokens, and a deterministic roll of 3.
**Steps:** Select the source and target; inspect the one-token range extension _before_ rolling; confirm payment; roll; inspect the two-token shortfall; choose whether to pay for success; inspect the changed building color, point and unchanged city owner. Finish with the consequence of declining the boost and the one-success-per-turn limit.
**Check:** Fix the tutorial seed, rather than replacing engine dice. Range payment and success boost remain distinct. Neither declining nor an unaffordable boost should consume resources accidentally. Show the running cost and next step throughout.
### 8. Incidents and hostile units (`incidents-hostiles`, interaction, 8 minutes)
**Problem:** Hostile placement guides are mistaken for player actions; Heavy Flood and Myths decisions are misunderstood.
**Position:** One incident is imminent; separate saved subpositions demonstrate Heavy Flood and a pirate/barbarian incident.
**Steps:** Trigger and read the incident; inspect every affected city for Heavy Flood; choose protection where permitted; verify the remaining cities' results; follow a barbarian placement/movement guide; identify horned helmets and a barbarian city's helmet flag; identify pirate flags and their sea effects. Explain barren and exhausted terrain separately.
**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)
**Problem:** “Free action” is read as “free payment”; draft, recruit and card play are conflated.
**Position:** Great Prophet available with a legal Temple construction, one recruitable leader and a Shogunate example in a separate checkpoint.
**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.
**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.
### 10. Wonders and ownership (`wonders-ownership`, mastery, 7 minutes)
**Problem:** Building a wonder, owning it after capture, and triggering its ability are confused; fractional scoring surprises players.
**Position:** Separate checkpoints with Great Lighthouse, Great Mausoleum, Great Explorer and a captured Pyramid.
**Steps:** Activate a Lighthouse city and decide on its optional ship; verify this is a follow-up to that activation, not another free city activation; inspect Mausoleum's owner restriction; meet Great Explorer's exploration conditions and inspect its optional benefit; compare Pyramid's builder points with its current owner's points. Inspect the same score in the viewer and BGS sidebar.
**Check:** Validate each trigger against current engine rules. The Pyramid builder receives 5.1 points; ownership alone gives 0 wonder points. A failed ability action cannot partially update the game.
### 11. Objectives and the end of an age (`objectives-ages`, mastery, 6 minutes)
**Problem:** Players expect generic battle wins to satisfy objectives with extra conditions, or try to claim end-of-age objectives early.
**Position:** One during-play objective and one end-of-age objective, with progress one step from completion.
**Steps:** Read the actual condition; perform the qualifying action; claim the eligible objective; advance to age-end checks; claim the age-end objective; observe free research and new cards. Contrast the final age, which ends before those rewards.
**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.
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.
## 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.
| Chapter | Interactive exercise in this release |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
| Your first turn | Collect, research Storage, end the turn with an action unused. |
| 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. |
| Ships and passengers | Board, sail, then land 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. |
| 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. |
Tutorial shortcuts issue the same validated engine moves as the board controls. 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.

View file

@ -1,12 +1,12 @@
{
"name": "@boardgamers/clash-web-client",
"version": "0.1.1",
"version": "0.1.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@boardgamers/clash-web-client",
"version": "0.1.1",
"version": "0.1.2",
"dependencies": {
"@boardgamers/protocol": "0.9.0",
"lucide-svelte": "^0.577.0",

View file

@ -1,15 +1,18 @@
{
"name": "@boardgamers/clash-web-client",
"version": "0.1.1",
"version": "0.1.2",
"private": true,
"type": "module",
"scripts": {
"dev": "vite --host 127.0.0.1 --port 8643",
"build": "vite build",
"check": "svelte-check --tsconfig ./tsconfig.json",
"test": "node --experimental-strip-types --test src/*.test.ts",
"test": "node --experimental-strip-types --test src/*.test.ts && npm run test:locales",
"build:bridge": "bash scripts/build-bridge.sh",
"publish:bgs": "node scripts/publish.mjs"
"publish:bgs": "node scripts/publish.mjs",
"test:locales": "node ../scripts/check-locales.mjs src/localization",
"localization:extract": "node scripts/extract-localization.mjs",
"tutorial:fixtures": "node scripts/build-tutorial-fixtures.mjs"
},
"dependencies": {
"@boardgamers/protocol": "0.9.0",

View file

@ -0,0 +1,125 @@
import { createRequire } from 'node:module';
import fs from 'node:fs/promises';
const engine = createRequire(import.meta.url)('../.engine/server.js');
const directory = new URL('../src/tutorial/positions/', import.meta.url);
const base = JSON.parse(await engine.init(2, [], {}, 'clash-tutorial-v1', {}));
for (const [position, terrain] of Object.entries({
D2: 'Fertile',
D7: 'Fertile',
C2: 'Forest',
E2: 'Mountain',
D1: 'Water',
}))
base.map.tiles.find((t) => t[0] === position)[1] = terrain;
base.current_player_index = 0;
base.starting_player_index = 0;
base.players[0].name = 'You';
base.players[1].name = 'Opponent';
base.players[0].civilization = 'Rome';
base.players[0].cities = [{ position: 'D2', mood_state: 'Happy' }];
base.players[0].units = [{ position: 'D2', unit_type: 'Settler', id: 0 }];
base.players[0].available_leaders = ['Caesar', 'Augustus', 'Sulla'];
base.players[0].resources = {
food: 2,
wood: 3,
ore: 3,
ideas: 3,
gold: 3,
mood_tokens: 7,
culture_tokens: 7,
};
base.players[0].advances = ['Farming', 'Mining'];
base.players[1].cities = [{ position: 'D7', mood_state: 'Happy' }];
base.players[1].units = [{ position: 'D7', unit_type: 'Settler', id: 0 }];
async function fixture(name) {
const game = JSON.parse(
await fs.readFile(new URL(`../../server/tests/test_games/${name}.json`, import.meta.url), 'utf8'),
);
for (const npc of base.players.slice(2))
if (!game.players.some((p) => p.civilization === npc.civilization))
game.players.push({ ...npc, id: game.players.length, cities: [], units: [] });
game.current_player_index = 0;
return game;
}
for (const id of [
'first-turn',
'city-economy',
'activation-happiness',
'research-paths',
'movement-founding',
'sea-transport',
'cultural-influence',
'incidents-hostiles',
'cards-leaders',
'wonders-ownership',
'objectives-ages',
'platform-tools',
]) {
let g = structuredClone(base),
p = g.players[0];
if (id === 'city-economy') {
p.cities[0].city_pieces = { temple: 0 };
p.advances.push('Myths');
p.cities.push({ position: 'E3', mood_state: 'Happy' });
g.map.tiles.find((t) => t[0] === 'E3')[1] = 'Fertile';
}
if (id === 'activation-happiness') {
p.cities[0].mood_state = 'Neutral';
p.cities[0].activations = 1;
p.cities.push({ position: 'E3', mood_state: 'Angry' });
g.map.tiles.find((t) => t[0] === 'E3')[1] = 'Fertile';
}
if (id === 'research-paths') p.advances.push('Writing');
if (id === 'movement-founding') {
p.units.push({ id: 1, position: 'D2', unit_type: 'Settler' });
p.next_unit_id = 2;
}
if (id === 'sea-transport') {
g.map.tiles.find((t) => t[0] === 'C3')[1] = 'Water';
g.map.tiles.find((t) => t[0] === 'C2')[1] = 'Water';
g.map.tiles.find((t) => t[0] === 'D1')[1] = 'Water';
p.advances.push('Fishing', 'Tactics');
p.units.push({ id: 1, position: 'D1', unit_type: 'Ship' });
p.next_unit_id = 2;
g.map.tiles.find((t) => t[0] === 'D3')[1] = 'Water';
g.map.tiles.find((t) => t[0] === 'E3')[1] = 'Fertile';
}
if (id === 'cultural-influence') {
g = await fixture('base/cultural_influence_instant');
g.dice_roll_outcomes = [0];
g.players[0].civilization = 'Rome';
g.players[0].cities = [{ position: 'A1', mood_state: 'Happy' }];
g.players[0].resources.culture_tokens = 7;
g.players[1].cities[0].city_pieces = { temple: 1 };
}
if (id === 'incidents-hostiles') {
g = await fixture('incidents/earthquake/flood');
g.players[0].advances.push('Myths');
}
if (id === 'cards-leaders') {
p.advances.push('Tactics');
p.available_leaders = ['Caesar', 'Augustus', 'Sulla'];
}
if (id === 'wonders-ownership') {
g.map.tiles.find((t) => t[0] === 'D1')[1] = 'Water';
p.advances.push('Fishing', 'Myths');
p.cities[0].city_pieces = { wonders: ['GreatLighthouse'] };
p.resources.wood = 2;
}
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,
),
);
}
// Validate the fixture against the production engine before saving it.
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');

View file

@ -0,0 +1,117 @@
import fs from 'node:fs';
import path from 'node:path';
import ts from 'typescript';
import { parse } from 'svelte/compiler';
import { fileURLToPath } from 'node:url';
const root = fileURLToPath(new URL('..', import.meta.url));
const source = JSON.parse(fs.readFileSync(path.join(root, '../client/js/src/localization/en.json'), 'utf8'));
const existingSource = path.join(root, 'src/localization/en.json');
if (fs.existsSync(existingSource)) Object.assign(source, JSON.parse(fs.readFileSync(existingSource, 'utf8')));
const locations = new Map();
function add(value, file) {
const text = value.replace(/\s+/g, ' ').trim();
if (
!/[A-Za-z]/.test(text) ||
text.length < 2 ||
/^[-a-z0-9:/]+$/.test(text) ||
/^[#.:\[]/.test(text) ||
/^<[a-z]/.test(text) ||
/[A-Za-z]__[A-Za-z]/.test(text) ||
/=>|\\[bpdw]|\.\/(?:src|assets)|https?:|\.svg|\.wasm|rgba?\(|gradient\(|var\(|\d(?:px|rem)\b/.test(text)
)
return;
source[text] = text;
if (!locations.has(text)) locations.set(text, []);
locations.get(text).push(file);
}
function javascript(node, file) {
if (ts.isStringLiteral(node)) add(node.text, file);
if (ts.isTemplateExpression(node))
add(node.head.text + node.templateSpans.map((span, i) => `{p${i}}${span.literal.text}`).join(''), file);
ts.forEachChild(node, (child) => javascript(child, file));
}
function svelte(node, file) {
if (!node || typeof node !== 'object') return;
if (
node.type === 'Fragment' &&
node.nodes?.some((n) => n.type === 'ExpressionTag') &&
node.nodes.every((n) => ['Text', 'ExpressionTag', 'Comment'].includes(n.type))
) {
let index = 0;
add(
node.nodes
.map((n) => (n.type === 'Text' ? n.data : n.type === 'ExpressionTag' ? `{p${index++}}` : ''))
.join(''),
file,
);
}
if (node.type === 'Text') add(node.data, file);
if (node.type === 'Literal' && typeof node.value === 'string') add(node.value, file);
if (node.type === 'TemplateLiteral')
add(
node.quasis.map((q, i) => q.value.cooked + (i < node.expressions.length ? `{p${i}}` : '')).join(''),
file,
);
for (const [key, value] of Object.entries(node)) {
if (['css', 'start', 'end', 'loc'].includes(key)) continue;
if (Array.isArray(value)) value.forEach((v) => svelte(v, file));
else if (value && typeof value === 'object') svelte(value, file);
}
}
function frontend(directory) {
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
if (entry.isDirectory()) {
if (entry.name !== 'localization') frontend(path.join(directory, entry.name));
continue;
}
const name = entry.name;
if (/\.test\.ts$/.test(name) || !/\.(ts|svelte)$/.test(name)) continue;
const absolute = path.join(directory, name);
const content = fs.readFileSync(absolute, 'utf8');
const file = path.relative(root, absolute);
if (name.endsWith('.ts'))
javascript(ts.createSourceFile(name, content, ts.ScriptTarget.Latest, true), file);
else svelte(parse(content, { modern: true }), file);
}
}
frontend(path.join(root, 'src'));
const guide = path.join(root, 'node_modules/@boardgamers/protocol/dist/tutorial-dom.js');
javascript(
ts.createSourceFile(guide, fs.readFileSync(guide, 'utf8'), ts.ScriptTarget.Latest, true),
'protocol/tutorial/dom',
);
function rust(directory) {
for (const item of fs.readdirSync(directory, { withFileTypes: true })) {
const file = path.join(directory, item.name);
if (item.isDirectory()) rust(file);
else if (item.name.endsWith('.rs')) {
const content = fs.readFileSync(file, 'utf8');
for (const match of content.matchAll(/"((?:[^"\\]|\\.)*)"/g)) {
let value;
try {
value = JSON.parse(`"${match[1]}"`);
} catch {
continue;
}
let index = 0;
value = value.replace(/\{(?:[a-zA-Z_][a-zA-Z_0-9]*|(?::[^}]*)?)\}/g, () => `{p${index++}}`);
add(value, path.relative(root, file));
}
}
}
}
rust(path.join(root, '../server/src'));
// Atomic words occur inside pluralized/interpolated UI captions.
for (const word of 'action actions advance advances city cities card cards wonder wonders unit units point points event events marker markers activation activations leader leaders round rounds age ages mood culture building buildings of and or for to from at with without remaining left'.split(
' ',
))
source[word] = word;
for (const phrase of ['event marker', 'event markers', 'Once per turn', 'City size']) source[phrase] = phrase;
const sorted = Object.fromEntries(Object.entries(source).sort(([a], [b]) => a.localeCompare(b)));
const sourceOutput =
process.argv.find((arg) => arg.startsWith('--source-output='))?.slice('--source-output='.length) ??
path.join(root, 'src/localization/en.json');
fs.writeFileSync(sourceOutput, JSON.stringify(sorted, null, 2) + '\n');
const out = process.argv.find((arg) => arg.startsWith('--locations='))?.slice('--locations='.length);
if (out) fs.writeFileSync(out, JSON.stringify(Object.fromEntries(locations), null, 2) + '\n');
console.log(`${Object.keys(source).length} source strings extracted`);

View file

@ -39,13 +39,25 @@ export function previewApi(): Plugin {
const url = new URL(req.url ?? '/', 'http://127.0.0.1:8643');
if (url.pathname.startsWith('/bundle/')) {
const asset = url.pathname.slice(8);
if (!['viewer.js', 'server_bg.wasm', 'engine/server.js', 'engine/server_bg.wasm'].includes(asset)) {
if (
!/^[a-zA-Z0-9_-]+\.(?:js|wasm|json|woff2)$/.test(asset) &&
!['engine/server.js', 'engine/server_bg.wasm'].includes(asset)
) {
res.statusCode = 404;
res.end();
return;
}
try {
res.setHeader('content-type', asset.endsWith('.wasm') ? 'application/wasm' : 'text/javascript');
res.setHeader(
'content-type',
asset.endsWith('.wasm')
? 'application/wasm'
: asset.endsWith('.json')
? 'application/json'
: asset.endsWith('.woff2')
? 'font/woff2'
: 'text/javascript',
);
res.end(readFileSync(fileURLToPath(new URL('../dist/' + asset, import.meta.url))));
} catch {
res.statusCode = 404;

View file

@ -22,6 +22,13 @@ async function api(url, options = {}) {
return res.json();
}
const previous = await api(endpoint);
const declaredTutorial = JSON.parse(await fs.readFile(path.join(root, 'bgs-tutorial.json'), 'utf8'));
// Preserve admin edits when the same chapter versions are already registered.
const tutorialSignature = (value) => JSON.stringify(value?.chapters?.map(({ id, version }) => [id, version]));
const tutorial =
tutorialSignature(previous.tutorial) === tutorialSignature(declaredTutorial)
? previous.tutorial
: declaredTutorial;
const enginePath = process.argv.find((arg) => arg.startsWith('--engine='))?.slice('--engine='.length);
const engineBytes = enginePath ? await fs.readFile(path.resolve(enginePath)) : null;
let expectedEngine = previous.engine;
@ -70,6 +77,7 @@ console.log(
preferences,
settings,
options,
tutorial,
enginePackage: enginePath ?? null,
dryRun: process.argv.includes('--dry-run'),
},
@ -107,6 +115,7 @@ if (!process.argv.includes('--dry-run')) {
JSON.stringify(current.preferences) !== JSON.stringify(previous.preferences) ||
JSON.stringify(current.settings) !== JSON.stringify(previous.settings) ||
JSON.stringify(current.options) !== JSON.stringify(previous.options) ||
JSON.stringify(current.tutorial) !== JSON.stringify(previous.tutorial) ||
JSON.stringify(current.engine) !== JSON.stringify(previous.engine)
)
throw new Error('The viewer or preferences changed during upload; version metadata was not changed');
@ -124,7 +133,7 @@ if (!process.argv.includes('--dry-run')) {
await api(endpoint, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ viewer, preferences, settings, options }),
body: JSON.stringify({ viewer, preferences, settings, options, tutorial }),
});
const saved = await api(endpoint);
if (
@ -133,6 +142,7 @@ if (!process.argv.includes('--dry-run')) {
JSON.stringify(saved.preferences) !== JSON.stringify(preferences) ||
JSON.stringify(saved.settings) !== JSON.stringify(settings) ||
JSON.stringify(saved.options) !== JSON.stringify(options) ||
JSON.stringify(saved.tutorial) !== JSON.stringify(tutorial) ||
JSON.stringify(saved.engine) !== JSON.stringify(expectedEngine)
)
throw new Error('Published version verification failed; inspect the saved backup');

View file

@ -1,5 +1,7 @@
<script lang="ts">
import { formatPoints } from './score';
import { currentLocale, translateText } from './localization';
const translate = $derived((value: string) => translateText(value, $currentLocale));
import CollectionBonusHints from './CollectionBonusHints.svelte';
import BarbarianIcon from './BarbarianIcon.svelte';
import PlaybackPanel from './PlaybackPanel.svelte';
@ -651,7 +653,7 @@
class="brand"
onclick={() => controller.commands.openBoardgame()}
aria-label="About Clash of Cultures"
><span class="brand-name">Clash <i>of</i> Cultures</span><span class="mobile-era"
><span class="brand-name" translate="no">Clash <i>of</i> Cultures</span><span class="mobile-era"
>{#if $session.game?.options?.variant === 'Builder'}Builder ·
{/if}{#if $session.view?.civilizationDraft}Civilization draft{:else}Age {ageLabel(
$session.playback?.frame?.age ?? $session.game?.age ?? 1,
@ -738,8 +740,8 @@
<div
class="resource"
role="img"
aria-label={`${resourceNames[resource]}: ${current.resources?.[resource] ?? 0}${current.resource_limit?.[resource] !== undefined ? `, storage limit ${current.resource_limit[resource]}` : ''}`}
title={`${resourceNames[resource]}${current?.resource_limit?.[resource] !== undefined ? ` · Storage limit ${current.resource_limit[resource]}` : ''}`}
aria-label={`${translate(resourceNames[resource])}: ${current.resources?.[resource] ?? 0}${current.resource_limit?.[resource] !== undefined ? translate(`, storage limit ${current.resource_limit[resource]}`) : ''}`}
title={`${translate(resourceNames[resource])}${current?.resource_limit?.[resource] !== undefined ? translate(` · Storage limit ${current.resource_limit[resource]}`) : ''}`}
>
<span class="resource-icon {resource}"><Icon size={20} strokeWidth={1.8} /></span><span
><strong
@ -773,7 +775,15 @@
class:active={!!turnLabel}
style={`--player:${playerColor(player.index, $session.colorBlind, $session.playerColors)}`}
title={`Inspect ${player.civilization} (${player.index === $session.seat ? 'You' : player.name}): advances and victory points`}
aria-label={`${player.civilization}: ${formatPoints(player.score)} victory points. ${player.index === $session.seat ? 'You' : player.name}.${order ? ` Turn order ${order}.` : ''}${turnLabel ? ` ${turnLabel}.` : ''}${progressLabel ? ` ${progressLabel}.` : ''} View resources, advances and scores`}
aria-label={[
`${translate(player.civilization)}: ${formatPoints(player.score)} ${translate('victory points')}`,
player.index === $session.seat ? translate('You') : player.name,
order ? translate(`Turn order ${order}.`).replace(/\.$/u, '') : '',
turnLabel ? translate(turnLabel) : '',
progressLabel ? translate(progressLabel) : '',
]
.filter(Boolean)
.join('. ')}
onclick={() => controller.patch({ scorePlayer: player.index })}
onmouseenter={(e) => {
const r = e.currentTarget.getBoundingClientRect();
@ -1022,8 +1032,8 @@
onclick={() => controller.openCities(c.position)}
><span class="city-thumb"><Landmark size={25} /></span><span
><strong
>{identity?.civilization}
{c.capital ? 'Capital' : 'City'}{#if c.capital}<Crown
>{translate(identity?.civilization ?? '')}
{translate(c.capital ? 'Capital' : 'City')}{#if c.capital}<Crown
size={11}
aria-label="Original capital"
/>{/if}</strong
@ -1039,7 +1049,12 @@
>{/each}
</div>
</section>
<div class="board-toolbar" class:has-redo={$session.view?.canRedo} aria-label="Game controls">
<div
class="board-toolbar"
data-tutorial="actions"
class:has-redo={$session.view?.canRedo}
aria-label="Game controls"
>
<div class="turn-banner" class:waiting={!!waiting} role="status" aria-live="polite">
{#if waiting}<Hourglass size={15} aria-hidden="true" />{:else}<span class="turn-light"></span>{/if}
<div class="turn-copy">

View file

@ -1,7 +1,9 @@
<script lang="ts">
import { ScrollText } from 'lucide-svelte';
let { remaining }: { remaining: number } = $props();
let label = $derived(`${remaining} event marker${remaining === 1 ? '' : 's'} left`);
let label = $derived(
remaining === 1 ? `${remaining} event marker left` : `${remaining} event markers left`,
);
</script>
<span

View file

@ -2,6 +2,8 @@
import { Wheat, Trees, Mountain, Lightbulb, Coins, Smile, Drama, Link } from 'lucide-svelte';
import type { CardReference } from './card-reference';
import { journalParts } from './model';
import { localizedParts } from './localized-parts';
import { currentLocale, translateText } from './localization';
import { namedTextParts, researchTextParts, type ResearchReference } from './research-links';
let {
text,
@ -30,7 +32,7 @@
objectives?: { name: string; player: number }[];
onObjective?: (reference: { name: string; player: number }) => void;
} = $props();
const parts = $derived(
const sourceParts = $derived(
journalParts(text, namedResources).flatMap((part) => {
if (part.resource || part.position) return [part];
return namedTextParts(part.text, onObjective ? objectives : []).flatMap(({ text, reference }) =>
@ -53,6 +55,10 @@
objective?: { name: string; player: number };
}[],
);
const translate = $derived((value: string) => translateText(value, $currentLocale));
const parts = $derived(
localizedParts(text, sourceParts, (value) => translateText(value, $currentLocale)) as typeof sourceParts,
);
const icons = {
food: Wheat,
wood: Trees,
@ -65,36 +71,38 @@
};
</script>
{#each parts as part}{#if part.card}<button
class="journal-research-link"
title={`View ${part.card.name} rules`}
onclick={() => onCard?.(part.card!)}>{part.text}</button
>
{:else if part.objective}<button
class="journal-research-link"
title={`View completed objective ${part.objective.name}`}
onclick={() => onObjective?.(part.objective!)}>{part.text}</button
>{:else if part.research}<button
class="journal-research-link"
title={`View ${part.research.name}`}
onclick={() => onResearch?.(part.research!)}>{part.text}</button
>{:else if part.resource}{@const Icon = icons[part.resource]}<span
class="inline-resource"
role={compactResources ? 'img' : undefined}
aria-label={compactResources ? part.text : undefined}
title={compactResources ? part.text : undefined}
><Icon size={14} aria-hidden="true" />{compactResources
? part.text.split(/\s+(?=[a-z])/i)[0]
: part.text}</span
>{:else if part.position && positions?.has(part.position) && onCoordinate}<button
class="coordinate-link"
title={`Highlight ${part.position} · Click to center on the map`}
aria-label={`Locate ${part.position} on the map`}
onmouseenter={() => onCoordinate?.(part.position!)}
onmouseleave={(event) => {
if (event.currentTarget !== document.activeElement) onCoordinate?.(null);
}}
onfocus={() => onCoordinate?.(part.position!)}
onblur={() => onCoordinate?.(null)}
onclick={() => onLocate?.(part.position!)}>{part.text}</button
>{:else}{part.text}{/if}{/each}
<span data-localized-text
>{#each parts as part}{#if part.card}<button
class="journal-research-link"
title={translate(`View ${part.card.name} rules`)}
onclick={() => onCard?.(part.card!)}>{part.text}</button
>
{:else if part.objective}<button
class="journal-research-link"
title={translate(`View completed objective ${part.objective.name}`)}
onclick={() => onObjective?.(part.objective!)}>{part.text}</button
>{:else if part.research}<button
class="journal-research-link"
title={translate(`View ${part.research.name}`)}
onclick={() => onResearch?.(part.research!)}>{part.text}</button
>{:else if part.resource}{@const Icon = icons[part.resource]}<span
class="inline-resource"
role={compactResources ? 'img' : undefined}
aria-label={compactResources ? part.text : undefined}
title={compactResources ? part.text : undefined}
><Icon size={14} aria-hidden="true" />{compactResources
? (part.text.match(/^\d+(?:\.\d+)?(?:\s*[-–]\s*\d+(?:\.\d+)?)?/u)?.[0] ?? part.text)
: part.text}</span
>{:else if part.position && positions?.has(part.position) && onCoordinate}<button
class="coordinate-link"
title={translate(`Highlight ${part.position} · Click to center on the map`)}
aria-label={translate(`Locate ${part.position} on the map`)}
onmouseenter={() => onCoordinate?.(part.position!)}
onmouseleave={(event) => {
if (event.currentTarget !== document.activeElement) onCoordinate?.(null);
}}
onfocus={() => onCoordinate?.(part.position!)}
onblur={() => onCoordinate?.(null)}
onclick={() => onLocate?.(part.position!)}>{part.text}</button
>{:else}{part.text}{/if}{/each}</span
>

View file

@ -12,3 +12,10 @@ async function initialize(): Promise<Bridge> {
await initWasm({ module_or_path: response });
return { webView, webCollectPreview, webRecruitPreview, webQuery };
}
/** Tutorials run the same initialized engine in an isolated local state. */
export async function loadTutorialEngine() {
await loadBridge();
const { tryMove, stripSecret, currentPlayer, webView, webQuery } = await import('../.bridge/server.js');
return { tryMove, stripSecret, currentPlayer, webView, webQuery };
}

View file

@ -12,7 +12,7 @@ let journal: string[] = [];
const send = (event: string, payload?: unknown) =>
frame.contentWindow?.postMessage({ source: 'clash-host', event, payload }, location.origin);
const preferences: Record<string, unknown> = {
locale: 'en',
locale: new URLSearchParams(location.search).get('locale') ?? 'en',
sound: true,
colorBlind: false,
mapView: '3d',

View file

@ -0,0 +1,137 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { createTranslator, resolveLocale } from './localization/runtime.js';
test('resolves regional BGS language preferences', () => {
assert.equal(resolveLocale('pt-PT'), 'pt-BR');
assert.equal(resolveLocale('zh-Hant-HK'), 'zh-TW');
assert.equal(resolveLocale('fr_CA'), 'fr');
assert.equal(resolveLocale('unknown'), 'en');
});
test('translates parameterized rules without translating player names', () => {
const translator = createTranslator(
{ fr: { '{p0} gained {p1} food.': '{p0} a gagné {p1} nourriture.', Happy: 'Heureuse' } },
'fr',
);
translator.setNames(['Happy']);
assert.equal(translator.translate('Happy gained 2 food.'), 'Happy a gagné 2 nourriture.');
assert.equal(translator.translate('Happy'), 'Happy');
});
test('switching locales clears cached translations and preserves whitespace', () => {
const translator = createTranslator(
{ fr: { 'End turn': 'Fin du tour' }, de: { 'End turn': 'Zug beenden' } },
'fr',
);
assert.equal(translator.translate(' End turn\n'), ' Fin du tour\n');
translator.setLocale('de');
assert.equal(translator.translate(' End turn\n'), ' Zug beenden\n');
translator.setLocale('en');
assert.equal(translator.translate(' End turn\n'), ' End turn\n');
});
import { createCatalogLoader } from './localization/loader.js';
test('English downloads nothing; concurrent French loads fetch only French once', async () => {
const calls: string[] = [];
const loader = createCatalogLoader(
{ './fr.json': '/fr.json', './de.json': '/de.json' },
async (url: string) => {
calls.push(url);
return { ok: true, json: async () => ({ Research: 'Recherche' }) };
},
);
await loader.load('en');
assert.deepEqual(calls, []);
assert.deepEqual(await Promise.all([loader.load('fr'), loader.load('fr-CA')]), ['fr', 'fr']);
assert.deepEqual(calls, ['/fr.json']);
await loader.load('fr');
assert.deepEqual(calls, ['/fr.json']);
assert.deepEqual(loader.catalogs.fr, { Research: 'Recherche' });
});
test('a failed catalog is retryable and never cached as a success', async () => {
let attempts = 0;
const loader = createCatalogLoader({ './fr.json': '/fr.json' }, async () => {
attempts++;
return attempts === 1
? { ok: false, status: 503 }
: { ok: true, json: async () => ({ Research: 'Recherche' }) };
});
await assert.rejects(loader.load('fr'), /503/);
assert.equal(loader.catalogs.fr, undefined);
assert.equal(await loader.load('fr'), 'fr');
assert.equal(attempts, 2);
});
test('malformed catalog contents are rejected', async () => {
const loader = createCatalogLoader({ './fr.json': '/fr.json' }, async () => ({
ok: true,
json: async () => ({ Research: 42 }),
}));
await assert.rejects(loader.load('fr'), /Invalid language catalog/);
assert.equal(loader.catalogs.fr, undefined);
});
import { mountLocalization } from './localization/runtime.js';
test('split Svelte text preserves live values through translation and locale switches', () => {
let notify: (records: unknown[]) => void = () => {};
const originalObserver = globalThis.MutationObserver;
globalThis.MutationObserver = class {
constructor(callback: (records: unknown[]) => void) {
notify = callback;
}
observe() {}
disconnect() {}
} as unknown as typeof MutationObserver;
const attributes = new Map<string, string>();
const element: any = {
nodeType: 1,
childNodes: [],
getAttribute: (key: string) => attributes.get(key) ?? null,
setAttribute: (key: string, value: string) => attributes.set(key, value),
removeAttribute: (key: string) => attributes.delete(key),
hasAttribute: (key: string) => attributes.has(key),
matches: () => false,
closest: () => null,
};
element.childNodes = ['You have ', '3', ' unused ', 'actions', '.'].map((data) => ({
nodeType: 3,
data,
parentElement: element,
}));
try {
const localization = mountLocalization(
element,
{ fr: { 'You have {p0} unused {p1}.': 'Il reste {p0} {p1}.', actions: 'actions', action: 'action' } },
'fr',
);
const text = () => element.childNodes.map((node: any) => node.data).join('');
assert.equal(text(), 'Il reste 3 actions.');
// Svelte updates only its number and plural nodes, leaving static nodes alone.
element.childNodes[1].data = '1';
element.childNodes[3].data = 'action';
notify([{ type: 'characterData', target: element.childNodes[1] }]);
assert.equal(text(), 'Il reste 1 action.');
localization.setLocale('en');
assert.equal(text(), 'You have 1 unused action.');
localization.setLocale('fr');
assert.equal(text(), 'Il reste 1 action.');
localization.destroy();
} finally {
globalThis.MutationObserver = originalObserver;
}
});
test('translates numeric threshold captions without dropping the plus sign', () => {
const translator = createTranslator({ fr: { 'Roll total · need': 'Résultat total · requis' } }, 'fr');
assert.equal(translator.translate('Roll total · need 5+'), 'Résultat total · requis 5+');
});
test('translates resource quantities within payment labels', () => {
const translator = createTranslator({ fr: { 'Pay {p0}': 'Payer {p0}', mood: 'humeur' } }, 'fr');
assert.equal(translator.translate('Pay 1 mood'), 'Payer 1 humeur');
assert.equal(translator.translate('1–3 mood'), '1–3 humeur');
});

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,155 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Noto
Upstream-Contact: https://github.com/googlei18n/noto-fonts/issues
http://groups.google.com/group/noto-font
Source: https://github.com/googlei18n/noto-fonts
Files: *
Copyright:
2010,2012-2020, Google Inc.
2015-2020, Google LLC.
License-Grant:
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
License: OFL-1.1
Files:
debian/*
Copyright:
2013-2020, Jonas Smedegaard <dr@jones.dk>
2020, Purism, SPC
2013, Vasudev Kamath <kamathvasudev@gmail.com>
License-Grant:
This program is free software;
you can redistribute it and/or modify it
under the terms of the GNU General Public License
as published by the Free Software Foundation;
either version 3, or (at your option) any later version.
License: GPL-3+
Files:
debian/NotoMono/NotoMono-Regular.ttf
Copyright:
2007, Google Inc.
License-Grant:
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
License: OFL-1.1
License: OFL-1.1
PREAMBLE
.
The goals of the Open Font License (OFL) are to stimulate
worldwide development of collaborative font projects,
to support the font creation efforts
of academic and linguistic communities,
and to provide a free and open framework
in which fonts may be shared and improved
in partnership with others.
.
The OFL allows the licensed fonts to be used, studied,
modified and redistributed freely
as long as they are not sold by themselves.
The fonts, including any derivative works,
can be bundled, embedded,
redistributed and/or sold with any software
provided that any reserved names are not used
by derivative works.
The fonts and derivatives, however,
cannot be released under any other type of license.
The requirement for fonts to remain under this license
does not apply to any document
created using the fonts or their derivatives.
.
DEFINITIONS
.
"Font Software" refers to the set of files
released by the Copyright Holder(s) under this license
and clearly marked as such.
This may include source files, build scripts and documentation.
.
"Reserved Font Name" refers to any names specified as such
after the copyright statement(s).
.
"Original Version" refers to the collection
of Font Software components
as distributed by the Copyright Holder(s).
.
"Modified Version" refers to any derivative
made by adding to, deleting, or substituting --
in part or in whole --
any of the components of the Original Version,
by changing formats
or by porting the Font Software to a new environment.
.
"Author" refers to any designer, engineer, programmer,
technical writer or other person
who contributed to the Font Software.
.
PERMISSION & CONDITIONS
.
Permission is hereby granted, free of charge,
to any person obtaining a copy of the Font Software,
to use, study, copy, merge, embed, modify, redistribute,
and sell modified and unmodified copies of the Font Software,
subject to the following conditions:
.
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions,
may be sold by itself.
.
2) Original or Modified Versions of the Font Software
may be bundled, redistributed and/or sold with any software,
provided that each copy contains the above copyright notice
and this license.
These can be included either as stand-alone text files,
human-readable headers or in the appropriate
machine-readable metadata fields within text or binary files
as long as those fields can be easily viewed by the user.
.
3) No Modified Version of the Font Software may use
the Reserved Font Name(s)
unless explicit written permission is granted
by the corresponding Copyright Holder.
This restriction only applies to the primary font name
as presented to the users.
.
4) The name(s) of the Copyright Holder(s)
or the Author(s) of the Font Software
shall not be used to promote,
endorse or advertise any Modified Version,
except to acknowledge the contribution(s)
of the Copyright Holder(s) and the Author(s)
or with their explicit written permission.
.
5) The Font Software,
modified or unmodified, in part or in whole,
must be distributed entirely under this license,
and must not be distributed under any other license.
The requirement for fonts to remain under this license
does not apply to any document
created using the Font Software.
.
TERMINATION
.
This license becomes null and void
if any of the above conditions are not met.
.
DISCLAIMER
.
THE FONT SOFTWARE IS PROVIDED "AS IS",
WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO
ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT.
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF THE USE OR INABILITY TO USE
THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
License: GPL-3+
License-Reference: /usr/share/common-licenses/GPL-3

View file

@ -0,0 +1,483 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: noto-cjk
Upstream-Contact: https://github.com/notofonts/noto-cjk/issues
Source: https://github.com/notofonts/noto-cjk
Files-Excluded:
.gitattributes
.gitignore
Sans/Mono/NotoSansMonoCJKhk-Bold.otf
Sans/Mono/NotoSansMonoCJKhk-Regular.otf
Sans/Mono/NotoSansMonoCJKjp-Bold.otf
Sans/Mono/NotoSansMonoCJKjp-Regular.otf
Sans/Mono/NotoSansMonoCJKkr-Bold.otf
Sans/Mono/NotoSansMonoCJKkr-Regular.otf
Sans/Mono/NotoSansMonoCJKsc-Bold.otf
Sans/Mono/NotoSansMonoCJKsc-Regular.otf
Sans/Mono/NotoSansMonoCJKtc-Bold.otf
Sans/Mono/NotoSansMonoCJKtc-Regular.otf
Sans/OTF/Japanese/NotoSansCJKjp-Black.otf
Sans/OTF/Japanese/NotoSansCJKjp-Bold.otf
Sans/OTF/Japanese/NotoSansCJKjp-DemiLight.otf
Sans/OTF/Japanese/NotoSansCJKjp-Light.otf
Sans/OTF/Japanese/NotoSansCJKjp-Medium.otf
Sans/OTF/Japanese/NotoSansCJKjp-Regular.otf
Sans/OTF/Japanese/NotoSansCJKjp-Thin.otf
Sans/OTF/Korean/NotoSansCJKkr-Black.otf
Sans/OTF/Korean/NotoSansCJKkr-Bold.otf
Sans/OTF/Korean/NotoSansCJKkr-DemiLight.otf
Sans/OTF/Korean/NotoSansCJKkr-Light.otf
Sans/OTF/Korean/NotoSansCJKkr-Medium.otf
Sans/OTF/Korean/NotoSansCJKkr-Regular.otf
Sans/OTF/Korean/NotoSansCJKkr-Thin.otf
Sans/OTF/SimplifiedChinese/NotoSansCJKsc-Black.otf
Sans/OTF/SimplifiedChinese/NotoSansCJKsc-Bold.otf
Sans/OTF/SimplifiedChinese/NotoSansCJKsc-DemiLight.otf
Sans/OTF/SimplifiedChinese/NotoSansCJKsc-Light.otf
Sans/OTF/SimplifiedChinese/NotoSansCJKsc-Medium.otf
Sans/OTF/SimplifiedChinese/NotoSansCJKsc-Regular.otf
Sans/OTF/SimplifiedChinese/NotoSansCJKsc-Thin.otf
Sans/OTF/TraditionalChinese/NotoSansCJKtc-Black.otf
Sans/OTF/TraditionalChinese/NotoSansCJKtc-Bold.otf
Sans/OTF/TraditionalChinese/NotoSansCJKtc-DemiLight.otf
Sans/OTF/TraditionalChinese/NotoSansCJKtc-Light.otf
Sans/OTF/TraditionalChinese/NotoSansCJKtc-Medium.otf
Sans/OTF/TraditionalChinese/NotoSansCJKtc-Regular.otf
Sans/OTF/TraditionalChinese/NotoSansCJKtc-Thin.otf
Sans/OTF/TraditionalChineseHK/NotoSansCJKhk-Black.otf
Sans/OTF/TraditionalChineseHK/NotoSansCJKhk-Bold.otf
Sans/OTF/TraditionalChineseHK/NotoSansCJKhk-DemiLight.otf
Sans/OTF/TraditionalChineseHK/NotoSansCJKhk-Light.otf
Sans/OTF/TraditionalChineseHK/NotoSansCJKhk-Medium.otf
Sans/OTF/TraditionalChineseHK/NotoSansCJKhk-Regular.otf
Sans/OTF/TraditionalChineseHK/NotoSansCJKhk-Thin.otf
Sans/SubsetOTF/HK/NotoSansHK-Black.otf
Sans/SubsetOTF/HK/NotoSansHK-Bold.otf
Sans/SubsetOTF/HK/NotoSansHK-DemiLight.otf
Sans/SubsetOTF/HK/NotoSansHK-Light.otf
Sans/SubsetOTF/HK/NotoSansHK-Medium.otf
Sans/SubsetOTF/HK/NotoSansHK-Regular.otf
Sans/SubsetOTF/HK/NotoSansHK-Thin.otf
Sans/SubsetOTF/JP/NotoSansJP-Black.otf
Sans/SubsetOTF/JP/NotoSansJP-Bold.otf
Sans/SubsetOTF/JP/NotoSansJP-DemiLight.otf
Sans/SubsetOTF/JP/NotoSansJP-Light.otf
Sans/SubsetOTF/JP/NotoSansJP-Medium.otf
Sans/SubsetOTF/JP/NotoSansJP-Regular.otf
Sans/SubsetOTF/JP/NotoSansJP-Thin.otf
Sans/SubsetOTF/KR/NotoSansKR-Black.otf
Sans/SubsetOTF/KR/NotoSansKR-Bold.otf
Sans/SubsetOTF/KR/NotoSansKR-DemiLight.otf
Sans/SubsetOTF/KR/NotoSansKR-Light.otf
Sans/SubsetOTF/KR/NotoSansKR-Medium.otf
Sans/SubsetOTF/KR/NotoSansKR-Regular.otf
Sans/SubsetOTF/KR/NotoSansKR-Thin.otf
Sans/SubsetOTF/SC/NotoSansSC-Black.otf
Sans/SubsetOTF/SC/NotoSansSC-Bold.otf
Sans/SubsetOTF/SC/NotoSansSC-DemiLight.otf
Sans/SubsetOTF/SC/NotoSansSC-Light.otf
Sans/SubsetOTF/SC/NotoSansSC-Medium.otf
Sans/SubsetOTF/SC/NotoSansSC-Regular.otf
Sans/SubsetOTF/SC/NotoSansSC-Thin.otf
Sans/SubsetOTF/TC/NotoSansTC-Black.otf
Sans/SubsetOTF/TC/NotoSansTC-Bold.otf
Sans/SubsetOTF/TC/NotoSansTC-DemiLight.otf
Sans/SubsetOTF/TC/NotoSansTC-Light.otf
Sans/SubsetOTF/TC/NotoSansTC-Medium.otf
Sans/SubsetOTF/TC/NotoSansTC-Regular.otf
Sans/SubsetOTF/TC/NotoSansTC-Thin.otf
Sans/SuperOTC/NotoSansCJK.ttc.zip
Sans/Variable/OTC/NotoSansCJK-VF.ttf.ttc
Sans/Variable/OTC/NotoSansMonoCJK-VF.ttf.ttc
Sans/Variable/OTF/Mono/NotoSansMonoCJKhk-VF.otf
Sans/Variable/OTF/Mono/NotoSansMonoCJKjp-VF.otf
Sans/Variable/OTF/Mono/NotoSansMonoCJKkr-VF.otf
Sans/Variable/OTF/Mono/NotoSansMonoCJKsc-VF.otf
Sans/Variable/OTF/Mono/NotoSansMonoCJKtc-VF.otf
Sans/Variable/OTF/NotoSansCJKhk-VF.otf
Sans/Variable/OTF/NotoSansCJKjp-VF.otf
Sans/Variable/OTF/NotoSansCJKkr-VF.otf
Sans/Variable/OTF/NotoSansCJKsc-VF.otf
Sans/Variable/OTF/NotoSansCJKtc-VF.otf
Sans/Variable/OTF/Subset/NotoSansHK-VF.otf
Sans/Variable/OTF/Subset/NotoSansJP-VF.otf
Sans/Variable/OTF/Subset/NotoSansKR-VF.otf
Sans/Variable/OTF/Subset/NotoSansSC-VF.otf
Sans/Variable/OTF/Subset/NotoSansTC-VF.otf
Sans/Variable/TTF/Mono/NotoSansMonoCJKhk-VF.ttf
Sans/Variable/TTF/Mono/NotoSansMonoCJKjp-VF.ttf
Sans/Variable/TTF/Mono/NotoSansMonoCJKkr-VF.ttf
Sans/Variable/TTF/Mono/NotoSansMonoCJKsc-VF.ttf
Sans/Variable/TTF/Mono/NotoSansMonoCJKtc-VF.ttf
Sans/Variable/TTF/NotoSansCJKhk-VF.ttf
Sans/Variable/TTF/NotoSansCJKjp-VF.ttf
Sans/Variable/TTF/NotoSansCJKkr-VF.ttf
Sans/Variable/TTF/NotoSansCJKsc-VF.ttf
Sans/Variable/TTF/NotoSansCJKtc-VF.ttf
Sans/Variable/TTF/Subset/NotoSansHK-VF.ttf
Sans/Variable/TTF/Subset/NotoSansJP-VF.ttf
Sans/Variable/TTF/Subset/NotoSansKR-VF.ttf
Sans/Variable/TTF/Subset/NotoSansSC-VF.ttf
Sans/Variable/TTF/Subset/NotoSansTC-VF.ttf
Serif/OTF/Japanese/NotoSerifCJKjp-Black.otf
Serif/OTF/Japanese/NotoSerifCJKjp-Bold.otf
Serif/OTF/Japanese/NotoSerifCJKjp-ExtraLight.otf
Serif/OTF/Japanese/NotoSerifCJKjp-Light.otf
Serif/OTF/Japanese/NotoSerifCJKjp-Medium.otf
Serif/OTF/Japanese/NotoSerifCJKjp-Regular.otf
Serif/OTF/Japanese/NotoSerifCJKjp-SemiBold.otf
Serif/OTF/Korean/NotoSerifCJKkr-Black.otf
Serif/OTF/Korean/NotoSerifCJKkr-Bold.otf
Serif/OTF/Korean/NotoSerifCJKkr-ExtraLight.otf
Serif/OTF/Korean/NotoSerifCJKkr-Light.otf
Serif/OTF/Korean/NotoSerifCJKkr-Medium.otf
Serif/OTF/Korean/NotoSerifCJKkr-Regular.otf
Serif/OTF/Korean/NotoSerifCJKkr-SemiBold.otf
Serif/OTF/SimplifiedChinese/NotoSerifCJKsc-Black.otf
Serif/OTF/SimplifiedChinese/NotoSerifCJKsc-Bold.otf
Serif/OTF/SimplifiedChinese/NotoSerifCJKsc-ExtraLight.otf
Serif/OTF/SimplifiedChinese/NotoSerifCJKsc-Light.otf
Serif/OTF/SimplifiedChinese/NotoSerifCJKsc-Medium.otf
Serif/OTF/SimplifiedChinese/NotoSerifCJKsc-Regular.otf
Serif/OTF/SimplifiedChinese/NotoSerifCJKsc-SemiBold.otf
Serif/OTF/TraditionalChinese/NotoSerifCJKtc-Black.otf
Serif/OTF/TraditionalChinese/NotoSerifCJKtc-Bold.otf
Serif/OTF/TraditionalChinese/NotoSerifCJKtc-ExtraLight.otf
Serif/OTF/TraditionalChinese/NotoSerifCJKtc-Light.otf
Serif/OTF/TraditionalChinese/NotoSerifCJKtc-Medium.otf
Serif/OTF/TraditionalChinese/NotoSerifCJKtc-Regular.otf
Serif/OTF/TraditionalChinese/NotoSerifCJKtc-SemiBold.otf
Serif/OTF/TraditionalChineseHK/NotoSerifCJKhk-Black.otf
Serif/OTF/TraditionalChineseHK/NotoSerifCJKhk-Bold.otf
Serif/OTF/TraditionalChineseHK/NotoSerifCJKhk-ExtraLight.otf
Serif/OTF/TraditionalChineseHK/NotoSerifCJKhk-Light.otf
Serif/OTF/TraditionalChineseHK/NotoSerifCJKhk-Medium.otf
Serif/OTF/TraditionalChineseHK/NotoSerifCJKhk-Regular.otf
Serif/OTF/TraditionalChineseHK/NotoSerifCJKhk-SemiBold.otf
Serif/SubsetOTF/HK/NotoSerifHK-Black.otf
Serif/SubsetOTF/HK/NotoSerifHK-Bold.otf
Serif/SubsetOTF/HK/NotoSerifHK-ExtraLight.otf
Serif/SubsetOTF/HK/NotoSerifHK-Light.otf
Serif/SubsetOTF/HK/NotoSerifHK-Medium.otf
Serif/SubsetOTF/HK/NotoSerifHK-Regular.otf
Serif/SubsetOTF/HK/NotoSerifHK-SemiBold.otf
Serif/SubsetOTF/JP/NotoSerifJP-Black.otf
Serif/SubsetOTF/JP/NotoSerifJP-Bold.otf
Serif/SubsetOTF/JP/NotoSerifJP-ExtraLight.otf
Serif/SubsetOTF/JP/NotoSerifJP-Light.otf
Serif/SubsetOTF/JP/NotoSerifJP-Medium.otf
Serif/SubsetOTF/JP/NotoSerifJP-Regular.otf
Serif/SubsetOTF/JP/NotoSerifJP-SemiBold.otf
Serif/SubsetOTF/KR/NotoSerifKR-Black.otf
Serif/SubsetOTF/KR/NotoSerifKR-Bold.otf
Serif/SubsetOTF/KR/NotoSerifKR-ExtraLight.otf
Serif/SubsetOTF/KR/NotoSerifKR-Light.otf
Serif/SubsetOTF/KR/NotoSerifKR-Medium.otf
Serif/SubsetOTF/KR/NotoSerifKR-Regular.otf
Serif/SubsetOTF/KR/NotoSerifKR-SemiBold.otf
Serif/SubsetOTF/SC/NotoSerifSC-Black.otf
Serif/SubsetOTF/SC/NotoSerifSC-Bold.otf
Serif/SubsetOTF/SC/NotoSerifSC-ExtraLight.otf
Serif/SubsetOTF/SC/NotoSerifSC-Light.otf
Serif/SubsetOTF/SC/NotoSerifSC-Medium.otf
Serif/SubsetOTF/SC/NotoSerifSC-Regular.otf
Serif/SubsetOTF/SC/NotoSerifSC-SemiBold.otf
Serif/SubsetOTF/TC/NotoSerifTC-Black.otf
Serif/SubsetOTF/TC/NotoSerifTC-Bold.otf
Serif/SubsetOTF/TC/NotoSerifTC-ExtraLight.otf
Serif/SubsetOTF/TC/NotoSerifTC-Light.otf
Serif/SubsetOTF/TC/NotoSerifTC-Medium.otf
Serif/SubsetOTF/TC/NotoSerifTC-Regular.otf
Serif/SubsetOTF/TC/NotoSerifTC-SemiBold.otf
Serif/Variable/OTC/NotoSerifCJK-VF.ttf.ttc
Serif/Variable/OTF/NotoSerifCJKhk-VF.otf
Serif/Variable/OTF/NotoSerifCJKjp-VF.otf
Serif/Variable/OTF/NotoSerifCJKkr-VF.otf
Serif/Variable/OTF/NotoSerifCJKsc-VF.otf
Serif/Variable/OTF/NotoSerifCJKtc-VF.otf
Serif/Variable/OTF/Subset/NotoSerifHK-VF.otf
Serif/Variable/OTF/Subset/NotoSerifJP-VF.otf
Serif/Variable/OTF/Subset/NotoSerifKR-VF.otf
Serif/Variable/OTF/Subset/NotoSerifSC-VF.otf
Serif/Variable/OTF/Subset/NotoSerifTC-VF.otf
Serif/Variable/TTF/NotoSerifCJKhk-VF.ttf
Serif/Variable/TTF/NotoSerifCJKjp-VF.ttf
Serif/Variable/TTF/NotoSerifCJKkr-VF.ttf
Serif/Variable/TTF/NotoSerifCJKsc-VF.ttf
Serif/Variable/TTF/NotoSerifCJKtc-VF.ttf
Serif/Variable/TTF/Subset/NotoSerifHK-VF.ttf
Serif/Variable/TTF/Subset/NotoSerifJP-VF.ttf
Serif/Variable/TTF/Subset/NotoSerifKR-VF.ttf
Serif/Variable/TTF/Subset/NotoSerifSC-VF.ttf
Serif/Variable/TTF/Subset/NotoSerifTC-VF.ttf
Files: *
Copyright: 2010-2012, Google Corporation
License: SIL-1.1
Files: debian/*
Copyright: 2013, Vasudev Kamath <kamathvasudev@gmail.com>
2013-2015, Jonas Smedegaard <dr@jones.dk>
2015-2022, ChangZhuo Chen (陳昌倬) <czchen@debian.org>
License: GPL-3+
License: SIL-1.1
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
.
PREAMBLE
.
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to provide
a free and open framework in which fonts may be shared and improved in
partnership with others.
.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.
.
DEFINITIONS
.
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
.
"Original Version" refers to the collection of Font Software components
as distributed by the Copyright Holder(s).
.
"Modified Version" refers to any derivative made by adding to,
deleting, or substituting -- in part or in whole -- any of the
components of the Original Version, by changing formats or by porting
the Font Software to a new environment.
.
"Author" refers to any designer, engineer, programmer, technical writer
or other person who contributed to the Font Software.
.
PERMISSION & CONDITIONS
.
Permission is hereby granted, free of charge, to any person obtaining a
copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
.
1) Neither the Font Software nor any of its individual components, in
Original or Modified Versions, may be sold by itself.
.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.
.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
.
5) The Font Software, modified or unmodified, in part or in whole, must
be distributed entirely under this license, and must not be distributed
under any other license. The requirement for fonts to remain under this
license does not apply to any document created using the Font Software.
.
TERMINATION
.
This license becomes null and void if any of the above conditions are
not met.
.
DISCLAIMER
.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
License: GPL-3+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Noto
Upstream-Contact: https://github.com/googlei18n/noto-fonts/issues
http://groups.google.com/group/noto-font
Source: https://github.com/googlei18n/noto-fonts
Files: *
Copyright:
2010,2012-2020, Google Inc.
2015-2020, Google LLC.
License-Grant:
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
License: OFL-1.1
Files:
debian/*
Copyright:
2013-2020, Jonas Smedegaard <dr@jones.dk>
2020, Purism, SPC
2013, Vasudev Kamath <kamathvasudev@gmail.com>
License-Grant:
This program is free software;
you can redistribute it and/or modify it
under the terms of the GNU General Public License
as published by the Free Software Foundation;
either version 3, or (at your option) any later version.
License: GPL-3+
Files:
debian/NotoMono/NotoMono-Regular.ttf
Copyright:
2007, Google Inc.
License-Grant:
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
License: OFL-1.1
License: OFL-1.1
PREAMBLE
.
The goals of the Open Font License (OFL) are to stimulate
worldwide development of collaborative font projects,
to support the font creation efforts
of academic and linguistic communities,
and to provide a free and open framework
in which fonts may be shared and improved
in partnership with others.
.
The OFL allows the licensed fonts to be used, studied,
modified and redistributed freely
as long as they are not sold by themselves.
The fonts, including any derivative works,
can be bundled, embedded,
redistributed and/or sold with any software
provided that any reserved names are not used
by derivative works.
The fonts and derivatives, however,
cannot be released under any other type of license.
The requirement for fonts to remain under this license
does not apply to any document
created using the fonts or their derivatives.
.
DEFINITIONS
.
"Font Software" refers to the set of files
released by the Copyright Holder(s) under this license
and clearly marked as such.
This may include source files, build scripts and documentation.
.
"Reserved Font Name" refers to any names specified as such
after the copyright statement(s).
.
"Original Version" refers to the collection
of Font Software components
as distributed by the Copyright Holder(s).
.
"Modified Version" refers to any derivative
made by adding to, deleting, or substituting --
in part or in whole --
any of the components of the Original Version,
by changing formats
or by porting the Font Software to a new environment.
.
"Author" refers to any designer, engineer, programmer,
technical writer or other person
who contributed to the Font Software.
.
PERMISSION & CONDITIONS
.
Permission is hereby granted, free of charge,
to any person obtaining a copy of the Font Software,
to use, study, copy, merge, embed, modify, redistribute,
and sell modified and unmodified copies of the Font Software,
subject to the following conditions:
.
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions,
may be sold by itself.
.
2) Original or Modified Versions of the Font Software
may be bundled, redistributed and/or sold with any software,
provided that each copy contains the above copyright notice
and this license.
These can be included either as stand-alone text files,
human-readable headers or in the appropriate
machine-readable metadata fields within text or binary files
as long as those fields can be easily viewed by the user.
.
3) No Modified Version of the Font Software may use
the Reserved Font Name(s)
unless explicit written permission is granted
by the corresponding Copyright Holder.
This restriction only applies to the primary font name
as presented to the users.
.
4) The name(s) of the Copyright Holder(s)
or the Author(s) of the Font Software
shall not be used to promote,
endorse or advertise any Modified Version,
except to acknowledge the contribution(s)
of the Copyright Holder(s) and the Author(s)
or with their explicit written permission.
.
5) The Font Software,
modified or unmodified, in part or in whole,
must be distributed entirely under this license,
and must not be distributed under any other license.
The requirement for fonts to remain under this license
does not apply to any document
created using the Font Software.
.
TERMINATION
.
This license becomes null and void
if any of the above conditions are not met.
.
DISCLAIMER
.
THE FONT SOFTWARE IS PROVIDED "AS IS",
WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO
ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT.
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF THE USE OR INABILITY TO USE
THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
License: GPL-3+
License-Reference: /usr/share/common-licenses/GPL-3

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

21
web-client/src/localization/index.d.ts vendored Normal file
View file

@ -0,0 +1,21 @@
import type { TutorialMount } from '@boardgamers/protocol/tutorial';
export interface Localization {
readonly locale: string;
translate(text: string): string;
readonly ready: Promise<boolean>;
setLocale(locale: unknown): Promise<boolean>;
setState(state: unknown): void;
setNames(names: unknown[]): void;
refresh(): void;
destroy(): void;
}
export const catalogs: Record<string, Record<string, string>>;
export const languages: Record<string, string>;
export function resolveLocale(value: unknown): string;
export function translateText(text: string, locale?: string): string;
export function mountLocalization(target: Element, locale?: unknown): Localization;
export function localizeTutorial(mount: TutorialMount): TutorialMount;
export function loadLocale(locale: unknown): Promise<string>;
export const currentLocale: import('svelte/store').Writable<string>;

View file

@ -0,0 +1,98 @@
import localeCss from './rtl.css?inline';
import arabicFont from './fonts/Arabic.woff2?url&no-inline';
import devanagariFont from './fonts/Devanagari.woff2?url&no-inline';
import koreanFont from './fonts/Korean.woff2?url&no-inline';
import chineseFont from './fonts/Chinese.woff2?url&no-inline';
const fontFaces = [
['Arabic', arabicFont],
['Devanagari', devanagariFont],
['Korean', koreanFont],
['Chinese', chineseFont],
]
.map(
([name, url]) =>
`@font-face{font-family:"Clash ${name}";src:url(${JSON.stringify(url)}) format("woff2");font-display:swap}`,
)
.join('\n');
import { writable } from 'svelte/store';
export const currentLocale = writable('en');
import { createCatalogLoader } from './loader.js';
import { createTranslator, mountLocalization as mount, resolveLocale } from './runtime.js';
export { languages, resolveLocale } from './runtime.js';
const catalogUrls = import.meta.glob(['./*.json', '!./en.json'], {
eager: true,
query: '?url&no-inline',
import: 'default',
});
const loader = createCatalogLoader(catalogUrls);
export const catalogs = loader.catalogs;
const translators = new Map();
export function loadLocale(value) {
return loader.load(value);
}
export function translateText(text, locale = 'en') {
if (!translators.has(locale)) {
translators.set(locale, createTranslator(catalogs, locale));
}
return translators.get(locale).translate(text);
}
export function mountLocalization(target, locale) {
const style = target.ownerDocument.createElement('style');
style.textContent = localeCss + fontFaces;
target.ownerDocument.head.append(style);
const localization = mount(target, catalogs, 'en');
let revision = 0;
let ready = Promise.resolve(true);
function setLocale(value) {
const attempt = ++revision;
ready = loadLocale(value)
.then((loaded) => {
if (attempt !== revision) return false;
localization.setLocale(loaded);
currentLocale.set(loaded);
return true;
})
.catch((error) => {
console.warn('Could not load game language', error);
if (attempt !== revision) return false;
localization.setLocale('en');
currentLocale.set('en');
return true;
});
return ready;
}
setLocale(locale ?? target.ownerDocument.documentElement.lang ?? 'en');
return {
...localization,
setLocale,
get locale() {
return localization.locale;
},
get ready() {
return ready;
},
destroy() {
revision++;
localization.destroy();
style.remove();
},
};
}
export function localizeTutorial(mountTutorial) {
return async (target, options) => {
const localization = mountLocalization(target, options.locale);
try {
await localization.ready;
const dispose = await mountTutorial(target, options);
localization.refresh();
return () => {
localization.destroy();
dispose?.();
};
} catch (error) {
localization.destroy();
throw error;
}
};
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,44 @@
import { resolveLocale } from './runtime.js';
/** Keep a URL manifest in the viewer, and fetch only the selected catalog. */
/** @param {Record<string, string>} urls
* @param {(url: string, options: {signal: AbortSignal}) => Promise<{ok: boolean, status?: number, json?: () => Promise<unknown>}>} fetcher
*/
export function createCatalogLoader(urls, fetcher = (...args) => fetch(...args)) {
/** @type {Record<string, Record<string, string>>} */
const catalogs = { en: {} };
const pending = new Map();
function load(value) {
const locale = resolveLocale(value);
if (catalogs[locale]) return Promise.resolve(locale);
if (!pending.has(locale)) {
const request = (async () => {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 20000);
try {
const response = await fetcher(urls[`./${locale}.json`], { signal: controller.signal });
if (!response.ok) throw new Error(`Language ${locale}: HTTP ${response.status}`);
const catalog = await response.json();
if (
!catalog ||
typeof catalog !== 'object' ||
Array.isArray(catalog) ||
Object.values(catalog).some((value) => typeof value !== 'string')
) {
throw new Error(`Invalid language catalog: ${locale}`);
}
catalogs[locale] = catalog;
return locale;
} finally {
clearTimeout(timeout);
}
})().catch((error) => {
pending.delete(locale);
throw error;
});
pending.set(locale, request);
}
return pending.get(locale);
}
return { catalogs, load };
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,51 @@
/* Preserve map coordinates; only Persian reading surfaces use RTL. */
[data-clash-locale='fa']
:is(
p,
h1,
h2,
h3,
h4,
h5,
h6,
strong,
button,
label,
legend,
li,
summary,
textarea,
select,
option,
.hint,
.description,
.decision-description,
.tutorial-body
) {
direction: rtl;
unicode-bidi: plaintext;
text-align: start;
}
[data-clash-locale='fa'] :is(canvas, svg, code, pre, [translate='no'], [data-bgs-player]) {
direction: ltr;
unicode-bidi: isolate;
}
/* Browser font faces are fetched only when the selected locale uses them. */
[data-clash-locale='hi'] {
--clash-locale-font: 'Clash Devanagari';
}
[data-clash-locale='fa'] {
--clash-locale-font: 'Clash Arabic';
}
[data-clash-locale='ko'] {
--clash-locale-font: 'Clash Korean';
}
[data-clash-locale='zh-TW'] {
--clash-locale-font: 'Clash Chinese';
}
[data-clash-locale]:is([lang='hi'], [lang='fa'], [lang='ko'], [lang='zh-TW']),
[data-clash-locale]:is([lang='hi'], [lang='fa'], [lang='ko'], [lang='zh-TW'])
:is(h1, h2, h3, h4, h5, h6, button, input, select, textarea) {
font-family: 'DM Sans', var(--clash-locale-font), sans-serif;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,325 @@
export const languages = {
en: 'English',
de: 'Deutsch',
fr: 'Français',
pl: 'Polski',
ro: 'Română',
el: 'Ελληνικά',
hi: 'हिन्दी',
ru: 'Русский',
da: 'Dansk',
'pt-BR': 'Português (Brasil)',
ko: '한국어',
'zh-TW': '繁體中文',
vi: 'Tiếng Việt',
it: 'Italiano',
nl: 'Nederlands',
fa: 'فارسی',
};
export function resolveLocale(value) {
if (typeof value !== 'string') {
return 'en';
}
const tag = value.toLowerCase().replaceAll('_', '-');
const exact = Object.keys(languages).find((locale) => locale.toLowerCase() === tag);
if (exact) {
return exact;
}
if (tag === 'pt' || tag.startsWith('pt-')) {
return 'pt-BR';
}
if (/^zh-(?:tw|hk|mo|hant)(?:-|$)/.test(tag)) {
return 'zh-TW';
}
return Object.keys(languages).find((locale) => locale === tag.split('-')[0]) ?? 'en';
}
const normalize = (text) => text.replace(/\s+/g, ' ').trim();
export function createTranslator(catalogs, initialLocale = 'en') {
let locale = resolveLocale(initialLocale);
let names = new Set();
let patterns = [];
let upperCase = new Map();
const cache = new Map();
function prepare() {
cache.clear();
upperCase = new Map(
Object.entries(catalogs[locale] ?? {})
.filter(([source]) => !/\{p\d+\}/.test(source))
.map(([source, value]) => [source.toLocaleUpperCase(), value.toLocaleUpperCase()]),
);
patterns = Object.keys(catalogs[locale] ?? {})
.filter((source) => /\{p\d+\}/.test(source) && source.replace(/\{p\d+\}/g, '').trim().length >= 1)
.sort((a, b) => b.replace(/\{p\d+\}/g, '').length - a.replace(/\{p\d+\}/g, '').length)
.map((source) => ({ source, pieces: source.split(/(\{p\d+\})/) }))
.filter(({ pieces }) =>
pieces.every((piece, i) => i === 0 || i === pieces.length - 1 || i % 2 !== 0 || piece.length > 0),
);
}
function translate(value, depth = 0) {
if (typeof value !== 'string' || locale === 'en') {
return value;
}
const text = normalize(value);
if (!text || names.has(text) || !/[A-Za-zÀ-ž]/.test(text)) {
return value;
}
const catalog = catalogs[locale] ?? {};
let translated = Object.prototype.hasOwnProperty.call(catalog, text) ? catalog[text] : undefined;
if (translated === undefined && text === text.toLocaleUpperCase()) {
translated = upperCase.get(text);
}
if (translated === undefined && cache.has(text)) {
translated = cache.get(text);
}
// Tutorial headings contain a progress prefix. Translate the complete title
// before broad patterns such as "{p0} {p1} to {p2}" can split its grammar.
if (translated === undefined) {
const prefix = /^(\d+\s*\/\s*\d+\s*·\s*)(.+)$/u.exec(text);
if (prefix && depth < 2) {
translated = prefix[1] + translate(prefix[2], depth + 1);
}
}
if (translated === undefined && depth < 2 && text.length <= 2500) {
for (const { source, pieces } of patterns) {
if (!text.startsWith(pieces[0])) {
continue;
}
let offset = pieces[0].length;
const parameters = {};
let matches = true;
for (let i = 1; i < pieces.length; i += 2) {
const delimiter = pieces[i + 1];
const last = i + 2 >= pieces.length;
const end = last
? text.endsWith(delimiter)
? text.length - delimiter.length
: -1
: text.indexOf(delimiter, offset);
if (end < 0 || end - offset > 500) {
matches = false;
break;
}
parameters[pieces[i]] = text.slice(offset, end);
offset = end + delimiter.length;
}
if (!matches || offset !== text.length) {
continue;
}
translated = catalog[source].replace(/\{p\d+\}/g, (key) =>
translate(parameters[key] ?? key, depth + 1),
);
break;
}
}
if (translated === undefined) {
const match = /^(.*?)(\s*[:.!?—–·→←↑↓↗↙↘↖↻↺✓✗]\s*|\s+\d+(?:\s*\/\s*\d+)?\+?\s*)$/u.exec(text);
if (match && catalog[match[1]] !== undefined) {
translated = catalog[match[1]] + match[2];
}
}
if (translated === undefined) {
const quantity = /^(\d+(?:[.,]\d+)?(?:\s*[-–]\s*\d+(?:[.,]\d+)?)?\s+)(.+)$/u.exec(text);
if (quantity && catalog[quantity[2]] !== undefined) {
translated = quantity[1] + catalog[quantity[2]];
}
}
if (translated === undefined) {
const amount = /^(.*?[$€£◈])(\d+(?:[.,]\d+)?)$/.exec(text);
if (amount && catalog[amount[1]] !== undefined) {
translated = catalog[amount[1]] + amount[2];
}
}
if (translated === undefined) {
translated = text;
}
if (cache.size > 5000) {
cache.clear();
}
cache.set(text, translated);
return (
value.slice(0, value.indexOf(value.trimStart())) + translated + value.slice(value.trimEnd().length)
);
}
prepare();
return {
translate,
get locale() {
return locale;
},
setLocale(value) {
const next = resolveLocale(value);
if (next === locale) {
return false;
}
locale = next;
prepare();
return true;
},
setNames(values) {
const next = new Set(values.filter((value) => typeof value === 'string').map(normalize));
if (next.size === names.size && [...next].every((name) => names.has(name))) {
return false;
}
names = next;
cache.clear();
return true;
},
};
}
// Only presentation text is changed. Never translate player input or rewrite game state.
export function mountLocalization(target, catalogs, initialLocale = 'en') {
const translator = createTranslator(catalogs, initialLocale);
const initialAttributes = new Map(
['lang', 'dir', 'data-clash-locale'].map((key) => [key, target.getAttribute(key)]),
);
const originals = new WeakMap();
const textGroups = new WeakSet();
const attributes = ['title', 'aria-label', 'placeholder', 'alt'];
const excluded =
'script,style,code,pre,[contenteditable="true"],[translate="no"],[data-bgs-player],[data-localized-text],[data-message-id],.chat-message-text,.chat-message-body,.chat-content,.message-text,.chat-author,.chat-segment';
let destroyed = false;
function apply(node, attribute) {
const element = node.nodeType === 3 ? node.parentElement : node;
if (!element || element.closest?.(excluded)) {
return;
}
const value = attribute ? node.getAttribute(attribute) : node.data;
if (typeof value !== 'string') {
return;
}
let record = originals.get(node);
if (!record) {
record = new Map();
originals.set(node, record);
}
const key = attribute ?? 'text';
const previous = record.get(key);
const source = previous?.output === value ? previous.source : value;
const output = translator.translate(source);
record.set(key, { source, output });
if (value !== output) {
if (attribute) {
node.setAttribute(attribute, output);
} else {
node.data = output;
}
}
}
function visit(node) {
if (destroyed) {
return;
}
if (node.nodeType === 3) {
apply(node);
return;
}
if (node.nodeType !== 1 && node !== target) {
return;
}
if (node.matches?.(excluded)) {
return;
}
for (const attr of attributes) {
if (node.hasAttribute?.(attr)) {
apply(node, attr);
}
}
if (node.matches?.('input,textarea')) {
return;
}
// Svelte can split one sentence into several adjacent text nodes around
// interpolations. Translate the complete sentence so grammar can reorder it.
const children = [...(node.childNodes ?? [])];
const texts = children.filter((child) => child.nodeType === 3);
if (texts.length > 1 && children.every((child) => child.nodeType === 3 || child.nodeType === 8)) {
const sources = texts.map((child) => {
const previous = originals.get(child)?.get('text');
return previous?.output === child.data ? previous.source : child.data;
});
const source = sources.join('');
const output = translator.translate(source);
if (output !== source || textGroups.has(node)) {
textGroups.add(node);
texts.forEach((child, index) => {
const value = index === 0 ? output : '';
const record = originals.get(child) ?? new Map();
record.set('text', { source: sources[index], output: value });
originals.set(child, record);
if (child.data !== value) child.data = value;
});
return;
}
}
for (const child of node.childNodes ?? []) {
visit(child);
}
}
const observer = new MutationObserver((records) => {
for (const record of records) {
if (record.type === 'characterData') {
visit(record.target.parentElement ?? record.target);
} else if (record.type === 'attributes') {
apply(record.target, record.attributeName);
} else {
for (const node of record.addedNodes) {
visit(node);
}
}
}
});
observer.observe(target, {
subtree: true,
childList: true,
characterData: true,
attributes: true,
attributeFilter: attributes,
});
function refresh() {
target.lang = translator.locale;
// Preserve board/grid coordinates even when the surrounding BGS page is RTL.
// Persian prose receives its own direction through the scoped stylesheet.
target.dir = 'ltr';
target.setAttribute('data-clash-locale', translator.locale);
visit(target);
}
refresh();
return {
translate: translator.translate,
get locale() {
return translator.locale;
},
setLocale(locale) {
if (translator.setLocale(locale)) {
refresh();
}
},
setNames(names) {
if (translator.setNames(names)) {
refresh();
}
},
setState(state) {
const players = state?.players ?? state?.game?.players;
if (players && typeof players === 'object') {
if (
translator.setNames(Object.values(players).flatMap((player) => [player?.name, player?.username]))
) {
refresh();
}
}
},
refresh,
destroy() {
destroyed = true;
observer.disconnect();
for (const [key, value] of initialAttributes) {
if (value === null) target.removeAttribute(key);
else target.setAttribute(key, value);
}
},
};
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,50 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { localizedParts } from './localized-parts.ts';
test('translates the whole sentence and keeps reordered references and IDs', () => {
const catalog: Record<string, string> = {
'Pay 2 food to research Math.': 'Math erforschen kostet 2 Nahrung.',
Math: 'Math',
'2 food': '2 Nahrung',
};
const result = localizedParts(
'Pay 2 food to research Math.',
[
{ text: 'Pay ' },
{ text: '2 food', resource: 'food' },
{ text: ' to research ' },
{ text: 'Math', research: { id: 'Math', name: 'Math' } },
{ text: '.' },
],
(text) => catalog[text] ?? text,
);
assert.equal(result.map((part) => part.text).join(''), 'Math erforschen kostet 2 Nahrung.');
assert.deepEqual(result[0], { text: 'Math', research: { id: 'Math', name: 'Math' } });
assert.deepEqual(result[2], { text: '2 Nahrung', resource: 'food' });
});
test('translates segments when no complete source sentence exists', () => {
assert.deepEqual(
localizedParts(
'Unknown sentence food',
[{ text: 'Unknown sentence ' }, { text: 'food', resource: 'food' }],
(text) => (text === 'food' ? 'Nahrung' : text),
),
[{ text: 'Unknown sentence ' }, { text: 'Nahrung', resource: 'food' }],
);
});
test('preserves complete prose when grammar inflects a reference label', () => {
const result = localizedParts(
'Pay food.',
[{ text: 'Pay ' }, { text: 'food', resource: 'food' }, { text: '.' }],
(text) => (text === 'Pay food.' ? 'Payer de la nourriture.' : text === 'food' ? 'Nourriture' : text),
);
assert.equal(result.map((part) => part.text).join(''), 'Payer de la nourriture.');
});
test('does not attach a short advance reference inside a longer translated word', () => {
const result=localizedParts('A lawgiver knows Law.',[{text:'A lawgiver knows '},{text:'Law',research:{id:'Law'}},{text:'.'}],(text)=>text==='A lawgiver knows Law.'?'Ein Rechtgeber kennt Recht.':text==='Law'?'Recht':text);
assert.deepEqual(result,[{text:'Ein Rechtgeber kennt '},{text:'Recht',research:{id:'Law'}},{text:'.'}]);
});

View file

@ -0,0 +1,47 @@
/** Translate complete sentences before restoring their interactive references.
* References retain engine IDs; only visible labels are translated.
*/
export function localizedParts<T extends { text: string }>(
source: string,
parts: T[],
translate: (text: string) => string,
): (T | { text: string })[] {
const translated = translate(source);
if (translated === source) return parts.map((part) => ({ ...part, text: translate(part.text) }));
const labels = parts
.filter((part) => Object.keys(part).some((key) => key !== 'text'))
.map((part) => ({ part, label: translate(part.text) }));
const result: (T | { text: string })[] = [];
let offset = 0;
while (offset < translated.length) {
const candidates = labels
.flatMap(({ part, label }) => {
if (!label) return [];
const pattern = new RegExp(label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'giu');
for (const match of translated.slice(offset).matchAll(pattern)) {
const index = offset + match.index;
const end = index + match[0].length;
const cjk = /[\p{Script=Han}\p{Script=Hangul}]/u.test(label);
const word = /[\p{L}\p{N}_]/u;
if (
!cjk &&
((index > 0 && word.test(label[0]) && word.test(translated[index - 1])) ||
(end < translated.length && word.test(label.at(-1)!) && word.test(translated[end])))
)
continue;
return [{ part, label: match[0], index }];
}
return [];
})
.sort((a, b) => a.index - b.index || b.label.length - a.label.length);
const next = candidates[0];
if (!next) {
result.push({ text: translated.slice(offset) });
break;
}
if (next.index > offset) result.push({ text: translated.slice(offset, next.index) });
result.push({ ...next.part, text: next.label });
offset = next.index + next.label.length;
}
return result;
}

View file

@ -0,0 +1,116 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import { readFileSync } from 'node:fs';
import { createTutorial } from '@boardgamers/protocol/tutorial';
import { chapters, createLesson } from './tutorial/lessons.ts';
const engine = createRequire(import.meta.url)('../.engine/server.js');
for (const chapter of chapters) {
test(`tutorial ${chapter.id}: complete walkthrough and atomic rejection`, async () => {
const lesson = createLesson(
chapter.id,
engine,
readFileSync(new URL(`./tutorial/positions/${chapter.id}.json`, import.meta.url), 'utf8'),
);
const saved = new Map<string, string>();
const storage = {
getItem: (key: string) => saved.get(key) ?? null,
setItem: (key: string, value: string) => {
saved.set(key, value);
},
};
const controller = await createTutorial({ ...lesson, storage });
for (let guard = 0; !controller.snapshot.completed && guard < 30; guard++) {
const before = controller.snapshot.state;
assert.equal(await controller.play({ step: 'unrelated', kind: 'move', move: 'Undo' }), false);
assert.equal(controller.snapshot.state, before);
const step = lesson.steps[controller.snapshot.step];
if (controller.snapshot.canContinue) {
await controller.continue();
continue;
}
const offers = step.offers(before);
assert.ok(offers.length, `No legal actions at ${chapter.id}/${step.id}`);
let accepted = false;
for (const offer of offers)
if (await controller.play(offer.action)) {
accepted = true;
break;
}
assert.ok(accepted, `No accepted actions at ${chapter.id}/${step.id}: ${controller.snapshot.error}`);
}
assert.ok(controller.snapshot.completed);
const final = JSON.parse(controller.snapshot.state.game);
const initial = JSON.parse(lesson.initialState().game);
if (chapter.id === 'first-turn') assert.equal(engine.currentPlayer(controller.snapshot.state.game), 1);
if (chapter.id === 'research-paths') {
assert.ok(final.players[0].advances.includes('Math'));
assert.ok(final.players[0].advances.includes('Engineering'));
assert.equal(final.actions_left, initial.actions_left - 2);
}
if (chapter.id === 'activation-happiness') {
assert.equal(final.players[0].cities[0].mood_state, 'Neutral');
assert.equal(final.players[0].cities[0].activations, 2);
assert.equal(final.players[0].cities[1].mood_state, 'Neutral');
assert.equal(final.players[0].cities[1].activations ?? 0, 0);
}
if (chapter.id === 'sea-transport') {
const view = JSON.parse(engine.webView(engine.stripSecret(controller.snapshot.state.game, 0), 0));
const settler = view.units.find((unit: any) => unit.type === 'Settler');
assert.equal(settler.position, 'E3');
assert.equal(settler.carrier, null);
}
if (chapter.id === 'cultural-influence') {
assert.equal(final.successful_cultural_influence, true);
assert.equal(final.players[1].cities[0].city_pieces.temple, 0);
}
if (chapter.id === 'wonders-ownership') {
assert.equal(final.actions_left, initial.actions_left - 1);
assert.equal(final.players[0].cities[0].activations, 1);
assert.equal(final.players[0].units.filter((unit: any) => unit.unit_type === 'Ship').length, 1);
}
if (chapter.id === 'incidents-hostiles') {
assert.equal(engine.currentPlayer(controller.snapshot.state.game), 0);
assert.deepEqual(
final.players[0].cities.map((city: any) => city.mood_state),
initial.players[0].cities.map((city: any) => city.mood_state),
);
assert.ok(
final.players[1].cities.some(
(city: any, index: number) => city.mood_state !== initial.players[1].cities[index].mood_state,
),
);
}
if (chapter.id === 'objectives-ages') assert.equal(final.players[0].completed_objectives.length, 1);
const restored = await createTutorial({ ...lesson, storage });
assert.ok(restored.snapshot.completed, 'Validated saved history restores completion');
assert.deepEqual(restored.snapshot.state, controller.snapshot.state);
restored.destroy();
await controller.restart();
assert.equal(controller.snapshot.step, 0);
assert.equal(controller.snapshot.state.game, lesson.initialState().game);
controller.destroy();
});
}
test('engine failure leaves tutorial game, completion and history unchanged', async () => {
const initialGame = readFileSync(new URL('./tutorial/positions/first-turn.json', import.meta.url), 'utf8');
const lesson = createLesson(
'first-turn',
{
...engine,
tryMove: () => {
throw new Error('Rejected by engine');
},
},
initialGame,
);
const controller = await createTutorial(lesson);
await controller.continue();
const before = controller.snapshot.state;
assert.equal(await controller.play(lesson.steps[controller.snapshot.step].offers(before)[0].action), false);
assert.deepEqual(controller.snapshot.state, before);
assert.equal(controller.snapshot.step, 1);
assert.match(controller.snapshot.error, /Rejected by engine/);
controller.destroy();
});

View file

@ -0,0 +1,674 @@
import type { TutorialOptions, TutorialStep } from '@boardgamers/protocol/tutorial';
import type { Move } from '../types.ts';
export interface TutorialEngine {
tryMove(game: string, action: string, player: number): string;
stripSecret(game: string, player?: number): string;
webView(game: string, player?: number): string;
webQuery(game: string, player: number, query: string): string;
currentPlayer(game: string): number;
}
export interface State {
game: string;
done: string[];
}
export type Action =
{ step: string; kind: 'move'; move: Move } | { step: string; kind: 'answer'; answer: string };
export interface Offer {
label: string;
action: Action;
}
type Kind =
| 'collect'
| 'storage'
| 'math'
| 'engineering'
| 'end'
| 'happiness'
| 'walk'
| 'stop'
| 'found'
| 'explore'
| 'orientation'
| 'embark'
| 'sail'
| 'land'
| 'influence'
| 'range'
| 'boost'
| 'incident'
| 'protect'
| 'leader'
| 'lighthouse'
| 'draft'
| 'objective'
| 'undo';
interface LessonStep {
id: string;
title: string;
text: string;
kind?: Kind;
answers?: string[];
correct?: string;
hint?: string;
}
export const sections = [
{
id: 'basics',
title: 'The basics',
description: 'Take your first turn, improve your cities and plan research.',
},
{
id: 'expansion',
title: 'Expansion',
description: 'Move groups, explore regions and transport units by sea.',
},
{
id: 'interaction',
title: 'Interaction',
description: 'Resolve cultural influence and incidents one decision at a time.',
},
{ 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.',
},
];
export const chapters: {
id: string;
title: string;
section: string;
description: string;
version: number;
steps: LessonStep[];
}[] = [
{
id: 'first-turn',
title: 'Your first turn',
section: 'basics',
description: 'Learn the three-action turn through collection and research.',
version: 1,
steps: [
{
id: 'turn',
title: 'Your turn, three actions',
text: 'The active civilization is marked in turn order. You have three actions. Opening a panel or selecting a piece does not spend an action.',
},
{
id: 'collect',
title: 'Collect once',
text: 'Collect from your happy city. Its size is 1, so its collection capacity is 2. The city becomes activated.',
kind: 'collect',
},
{
id: 'research',
title: 'Research Storage',
text: 'Research normally costs two resources in any mix of food, ideas and gold. Storage increases your food limit. Research also removes an event marker.',
kind: 'storage',
},
{
id: 'pass',
title: 'Finish your turn',
text: 'One action remains. You may end your turn without using every action. End the turn now.',
kind: 'end',
},
],
},
{
id: 'city-economy',
title: 'A productive city',
section: 'basics',
description: 'Understand happy-city capacity, terrain and storage.',
version: 1,
steps: [
{
id: 'capacity',
title: 'Size and capacity',
text: 'This happy size-2 city can collect up to 3 resources. A neutral city of the same size collects up to 2. Buildings increase size; happiness increases capacity.',
},
{
id: 'collection',
title: 'Choose useful yields',
text: 'Food storage is already full. Collect useful resources and inspect the overflow warning before confirming. Forest provides wood; mountains provide ore.',
kind: 'collect',
},
{
id: 'overflow',
title: 'Storage overflow',
text: 'What happens to resources beyond the storage limit?',
answers: ['The excess is lost', 'The excess becomes gold', 'It carries over to the next turn'],
correct: 'The excess is lost',
hint: 'Collection does not raise storage limits. Mood and culture tokens have no storage limit.',
},
],
},
{
id: 'activation-happiness',
title: 'Activation and happiness',
section: 'basics',
description: 'Improve multiple cities in one action without activating them.',
version: 1,
steps: [
{
id: 'mood',
title: 'Read the activation marker',
text: 'Your neutral city has already been activated this turn. Another activation lowers its mood. Increasing happiness is a separate action and does not activate cities.',
},
{
id: 'improve',
title: 'Improve both cities',
text: 'Improve the neutral city to Happy and the angry city to Neutral in one action. Each step costs mood tokens equal to the city size.',
kind: 'happiness',
},
{
id: 'collect',
title: 'Activate the improved city',
text: 'Collect from your original city. Its second activation lowers its mood from Happy to Neutral. Compare the mood icon with the activation count.',
kind: 'collect',
},
{
id: 'question',
title: 'Two different mechanics',
text: 'Does increasing happiness activate a city?',
answers: ['No, it changes mood only', 'Yes, it always activates the city'],
correct: 'No, it changes mood only',
},
],
},
{
id: 'research-paths',
title: 'Research with a plan',
section: 'basics',
description: 'Follow prerequisites and discover advances that become free.',
version: 1,
steps: [
{
id: 'math',
title: 'Research Math first',
text: 'Math makes Engineering and Roads free of resource cost. The tree shows a “Free with Math” hint before Math is unlocked. Research Math now.',
kind: 'math',
},
{
id: 'engineering',
title: 'Claim the free research',
text: 'Research Engineering. It costs no resources because you own Math, but it still uses a research action and an event marker.',
kind: 'engineering',
},
{
id: 'question',
title: 'Free resources or free action?',
text: 'What does Math waive for Engineering?',
answers: ['The resource payment', 'The action and every prerequisite'],
correct: 'The resource payment',
},
{
id: 'civs',
title: 'Civilization advances',
text: 'Civilization advances unlock when their prerequisites are met. Inspect your civilization below the regular research tree, then inspect other civilizations and their leaders.',
},
],
},
{
id: 'movement-founding',
title: 'Move, explore, found',
section: 'expansion',
description: 'Separate movement groups from actions and founding.',
version: 1,
steps: [
{
id: 'walk',
title: 'Move the settler',
text: 'A Move action can move up to three groups. Move the first settler to the nearby forest. Army movement requires Tactics; settlers do not.',
kind: 'walk',
},
{
id: 'stop',
title: 'Finish the Move action',
text: 'The Move action remains open for other groups. Finish movement before founding. A single unit cannot join two groups in the same Move action.',
kind: 'stop',
},
{
id: 'found',
title: 'Found a separate city',
text: 'Found a city on the settler’s empty land tile. Founding spends a separate action and replaces the settler with a settlement.',
kind: 'found',
},
{
id: 'explore',
title: 'Explore a region',
text: 'Move the second settler into unexplored land. Exploration reveals a four-hex region, rather than one isolated hex.',
kind: 'explore',
},
{
id: 'orientation',
title: 'Choose the revealed region',
text: 'Choose the orientation offered by the engine. The revealed terrain must allow the exploring unit to enter.',
kind: 'orientation',
},
],
},
{
id: 'sea-transport',
title: 'Ships and passengers',
section: 'expansion',
description: 'Board, sail and land with the right movement timing.',
version: 1,
steps: [
{
id: 'embark',
title: 'Board the ship',
text: 'Each ship can carry two land units. Board the nearby ship with your settler. Boarding uses that land group’s move.',
kind: 'embark',
},
{
id: 'sail',
title: 'Sail with the passenger',
text: 'Move the ship to the next sea tile. Its passenger travels with it, within the same Move action.',
kind: 'sail',
},
{
id: 'timing',
title: 'Landing after boarding',
text: 'Can this newly boarded settler land during the same Move action?',
answers: ['No, it needs another Move action', 'Yes, boarding gives an extra move'],
correct: 'No, it needs another Move action',
},
{
id: 'stop',
title: 'This Move action has finished',
text: 'All eligible groups have moved, so the engine has finished this Move action. Units already aboard before a Move action may sail and land in that action.',
},
{
id: 'land',
title: 'Land on empty land',
text: 'Use another Move action to land the passenger on adjacent empty land.',
kind: 'land',
},
],
},
{
id: 'cultural-influence',
title: 'Cultural influence',
section: 'interaction',
description: 'Pay for range, roll, then decide whether to boost the result.',
version: 1,
steps: [
{
id: 'target',
title: 'Choose source and target',
text: 'Target the enemy Temple from your city. Influence changes a building’s color; it does not transfer control of the city.',
kind: 'influence',
},
{
id: 'range',
title: 'Pay for range before rolling',
text: 'The target lies beyond your city’s normal range. Pay the required culture tokens to extend range. The roll is still hidden at this stage.',
kind: 'range',
},
{
id: 'boost',
title: 'Read the roll and shortfall',
text: 'The roll is below 5. You may pay culture tokens for the remaining shortfall, or decline and keep them. Pay for success in this lesson.',
kind: 'boost',
},
{
id: 'ownership',
title: 'Building color and city owner',
text: 'Who can still use the influenced building?',
answers: ['The city’s owner', 'Only the influencing civilization'],
correct: 'The city’s owner',
hint: 'You gain the building’s point; the city’s owner still uses it. Only one successful influence is allowed each turn.',
},
],
},
{
id: 'incidents-hostiles',
title: 'Incidents and hostile units',
section: 'interaction',
description: 'Read affected cities and resolve protection choices.',
version: 1,
steps: [
{
id: 'trigger',
title: 'Trigger the incident',
text: 'Your next advance uses the final event marker. Research Storage and read the incident that appears.',
kind: 'incident',
},
{
id: 'protect',
title: 'Protect affected cities',
text: 'Read which cities are affected. Myths can offer mood-token payments to protect them. Choose the offered protection; incidents do not always affect just one city.',
kind: 'protect',
},
{
id: 'hostiles',
title: 'Recognize hostile units',
text: 'Pirates carry flags and affect sea collection and Trade Routes. Barbarians wear horned helmets, and their cities use a helmet flag. Their placement and movement guides explain incident effects; they are not extra player actions.',
},
{
id: 'question',
title: 'Read the target list',
text: 'Should you assume every incident targets exactly one city?',
answers: ['No, read this incident’s affected cities', 'Yes, incidents always target one city'],
correct: 'No, read this incident’s affected cities',
},
],
},
{
id: 'cards-leaders',
title: 'Cards, leaders and free actions',
section: 'mastery',
description: 'Recruit a leader and distinguish payments from action costs.',
version: 1,
steps: [
{
id: 'leader',
title: 'Recruit a leader',
text: 'Recruit Caesar in your city. This costs one mood token, one culture token and one action, and activates the city. A leader is an army unit and needs Tactics to move.',
kind: 'leader',
},
{
id: 'free',
title: 'A free action can still cost resources',
text: 'Does “free action” always mean there is no resource payment?',
answers: ['No, pay any listed resource cost', 'Yes, every payment is waived'],
correct: 'No, pay any listed resource cost',
hint: 'Great Prophet grants a free construction action but still requires the Temple payment. Read each effect’s exact wording.',
},
{
id: 'draft',
title: 'Different kinds of draft',
text: 'Draft recruits one unit by military conscription. Shogunate card drafting and card play have separate allowances. Neither is the civilization-selection draft.',
},
],
},
{
id: 'wonders-ownership',
title: 'Wonders and ownership',
section: 'mastery',
description: 'Use Great Lighthouse and inspect builder versus owner points.',
version: 1,
steps: [
{
id: 'activate',
title: 'Activate Great Lighthouse’s city',
text: 'Collect from the city containing Great Lighthouse. Its optional ship follows this activation; it is not a second free city activation.',
kind: 'collect',
},
{
id: 'ship',
title: 'Choose the optional ship',
text: 'Choose the legal sea tile for the free ship. The city’s activation count and your remaining actions do not change again.',
kind: 'lighthouse',
},
{
id: 'score',
title: 'Builder points and ownership',
text: 'How many wonder points does merely owning a captured Great Pyramid give?',
answers: ['0 wonder points', '5.1 wonder points'],
correct: '0 wonder points',
hint: 'The civilization that built Great Pyramid receives 5.1 points. Ownership alone gives 0 wonder points.',
},
{
id: 'conditions',
title: 'Read each wonder’s trigger',
text: 'Great Mausoleum benefits its owner. Great Explorer requires its qualifying exploration. A wonder’s ability must satisfy its printed conditions; ownership is not a general permission to activate it freely.',
},
],
},
{
id: 'objectives-ages',
title: 'Objectives and the end of an age',
section: 'mastery',
description: 'Meet the exact objective condition and distinguish claim timing.',
version: 1,
steps: [
{
id: 'draft1',
title: 'Meet the first condition',
text: 'Your Draft objective requires recruiting with Draft twice this turn. Recruit one infantry using Draft in the legal city.',
kind: 'draft',
},
{
id: 'draft2',
title: 'Meet the complete condition',
text: 'Use Draft a second time. One qualifying recruitment alone was not enough for this objective.',
kind: 'draft',
},
{
id: 'claim',
title: 'Claim the eligible objective',
text: 'Claim Draft when the engine offers it. During-play objectives can be claimed when their condition is met; age-end objectives wait for their check.',
kind: 'objective',
},
{
id: 'age',
title: 'The final age',
text: 'Does the final age give another free advance and new cards after objective checks?',
answers: ['No, the game ends before those rewards', 'Yes, those rewards always happen'],
correct: 'No, the game ends before those rewards',
},
],
},
{
id: 'platform-tools',
title: 'Read, review and recover',
section: 'platform',
description: 'Use rule references and understand the boundary of undo.',
version: 1,
steps: [
{
id: 'journal',
title: 'Follow a journal reference',
text: 'Open the journal and select Storage to inspect its rules. Coordinates can locate places on the map. Last turn reviews actual actions and skips empty phase changes.',
},
{
id: 'undo',
title: 'Undo the harmless research',
text: 'Undo the research in this isolated example. Undo cannot cross an information reveal. Visual replay and analysis are separate tools.',
kind: 'undo',
},
{
id: 'analysis',
title: 'Analysis is an independent branch',
text: 'Does trying an action in analysis change the live game?',
answers: ['No, analysis is independent', 'Yes, analysis submits live moves'],
correct: 'No, analysis is independent',
},
{
id: 'settings',
title: 'Platform preferences',
text: 'Available actions only filters the choices shown; it does not make decisions for you. Colorblind display and map orientation are available in platform settings.',
},
],
},
];
const canonical = (value: unknown): string =>
JSON.stringify(value, (_key, item) =>
item && typeof item === 'object' && !Array.isArray(item)
? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b)))
: item,
);
export function createLesson(id: string, engine: TutorialEngine, initialGame: string) {
const chapter = chapters.find((chapter) => chapter.id === id);
if (!chapter) throw new Error(`Unknown Clash of Cultures chapter: ${id}`);
const view = (state: State): any => JSON.parse(engine.webView(engine.stripSecret(state.game, 0), 0));
const query = (state: State, input: unknown): any =>
JSON.parse(engine.webQuery(engine.stripSecret(state.game, 0), 0, JSON.stringify(input)));
function moves(state: State, kind: Kind): { label: string; move: Move }[] {
const v = view(state),
city =
v.cities?.find((c: any) => c.player === 0)?.position ??
JSON.parse(state.game).players[0].cities[0].position;
const one = (label: string, move: Move | null | undefined) => (move ? [{ label, move }] : []);
if (['storage', 'math', 'engineering', 'incident'].includes(kind)) {
const advance = kind === 'math' ? 'Math' : kind === 'engineering' ? 'Engineering' : 'Storage';
return one(`Research ${advance}`, v.advances.find((a: any) => a.id === advance)?.action);
}
if (kind === 'collect') {
const c = v.cities.find((c: any) => c.position === city);
const selections = c.choices
.filter((c: any) => !c.gain?.food)
.slice(0, 2)
.map((c: any) => ({ ...c, times: 1 }));
if (!selections.length) selections.push({ ...c.choices[0], times: 1 });
return one(
'Collect resources',
query(state, { kind: 'collect', city, selections, variant: 'Collect' }).action,
);
}
if (kind === 'happiness')
return one(
'Improve both cities',
query(state, {
kind: 'happiness',
cities: JSON.parse(state.game).players[0].cities.map((c: any) => [c.position, 1]),
variant: v.happinessActions[0].value,
lawgiver: false,
}).action,
);
if (kind === 'end') return one('End turn', v.canEndTurn ? { Playing: 'EndTurn' } : null);
if (kind === 'stop') return one('Finish movement', v.stopMovement);
if (kind === 'undo') return one('Undo the last action', v.canUndo ? 'Undo' : null);
if (kind === 'found')
return v.settlers
.filter((s: any) => s.foundAction)
.map((s: any) => ({ label: `Found city at ${s.position}`, move: s.foundAction }));
if (['walk', 'explore'].includes(kind))
return v.settlers
.flatMap((s: any) =>
s.destinations
.filter((d: any) => (kind === 'walk' ? d.terrain === 'Forest' : d.terrain === 'Unexplored'))
.map((d: any) => ({ label: `Move to ${d.position}`, move: d.action })),
)
.slice(0, 3);
if (kind === 'orientation')
return (v.explorationDecision?.choices ?? []).map((c: any) => ({
label: `Choose orientation ${c.rotation}`,
move: c.action,
}));
if (['embark', 'sail', 'land'].includes(kind)) {
const unit = v.units.find((u: any) => (kind === 'sail' ? u.type === 'Ship' : u.type === 'Settler'));
if (!unit) return [];
return query(state, { kind: 'movement', units: [unit.id], city: null })
.destinations.filter((d: any) =>
kind === 'embark'
? d.position === 'D1'
: kind === 'sail'
? d.position === 'D3'
: d.position === 'E3',
)
.map((d: any) => ({ label: `Move to ${d.position}`, move: d.action }));
}
if (kind === 'influence') {
const target = v.influence?.find((t: any) => t.position === 'C1' && t.name === 'Temple');
return one('Influence the Temple', target?.origins?.find((o: any) => o.position === 'A1')?.action);
}
if (['range', 'boost', 'protect'].includes(kind)) {
const field = v.decision?.fields?.[0];
if (!field) return [];
const payment = field.cost;
return one('Pay the listed cost', { Response: { Payment: [payment ?? field.cost] } });
}
if (kind === 'lighthouse') return one('Place the free ship', { Response: { SelectPositions: ['D1'] } });
if (kind === 'leader')
return one(
'Recruit Caesar',
query(state, { kind: 'recruit', city, units: { leader: 'Caesar' }, replaced: [] }).action,
);
if (kind === 'draft')
return one(
'Recruit one infantry with Draft',
query(state, {
kind: 'recruit',
city: 'A1',
units: { infantry: 1 },
replaced: [],
payment: { mood_tokens: 1 },
}).action,
);
if (kind === 'objective')
return (v.objectiveDecision?.cards ?? [])
.filter((o: any) => o.name?.includes('Draft'))
.map((o: any) => ({ label: o.name, move: o.action }));
return [];
}
function offers(step: LessonStep, state: State): Offer[] {
if (step.answers) {
const shift = [...step.id].reduce((sum, char) => sum + char.charCodeAt(0), 0) % step.answers.length;
return [...step.answers.slice(shift), ...step.answers.slice(0, shift)].map((answer) => ({
label: answer,
action: { kind: 'answer', answer, step: step.id },
}));
}
return step.kind
? moves(state, step.kind).map(({ label, move }) => ({
label,
action: { kind: 'move', move, step: step.id },
}))
: [];
}
const steps: (TutorialStep<State, Action> & { offers: (state: State) => Offer[] })[] = chapter.steps.map(
(step) => ({
...step,
target: step.kind ? 'actions' : undefined,
offers: (state) => offers(step, state),
complete: step.kind || step.answers ? (state) => state.done.includes(step.id) : undefined,
validateMove: (_state, action) =>
action.step !== step.id
? 'Follow the current lesson step.'
: action.kind === 'answer' && action.answer !== step.correct
? (step.hint ?? 'Read the explanation and try again.')
: undefined,
}),
);
function resolveIncidentOpponents(game: string): string {
for (let guard = 0; guard < 20; guard++) {
const player = engine.currentPlayer(game);
if (player === 0) return game;
const publicState = engine.stripSecret(game, player);
const decision = JSON.parse(engine.webView(publicState, player)).decision;
if (!decision) return game;
const values = decision.options.slice(0, decision.min).map((option: any) => option.value);
const payments = decision.fields.map(
(field: any) =>
field.choices?.find((pile: any) => Object.keys(pile).length === 0) ??
field.choices?.[0] ??
field.cost,
);
const offer = JSON.parse(
engine.webQuery(publicState, player, JSON.stringify({ kind: 'decision', values, payments })),
);
game = engine.tryMove(game, JSON.stringify(offer.action), player);
}
throw new Error('Follow the current lesson step.');
}
const lesson: TutorialOptions<State, Action> & { steps: typeof steps } = {
game: 'clash',
id,
version: chapter.version,
steps,
initialState: () => ({ game: initialGame, done: [] }),
move: (state, action) => {
const step = chapter.steps.find((step) => step.id === action.step);
if (!step || !offers(step, state).some((offer) => canonical(offer.action) === canonical(action)))
throw new Error('Use one of the actions offered for this lesson step.');
return {
game:
action.kind === 'move'
? id === 'incidents-hostiles'
? resolveIncidentOpponents(engine.tryMove(state.game, JSON.stringify(action.move), 0))
: engine.tryMove(state.game, JSON.stringify(action.move), 0)
: state.game,
done: [...state.done, step.id],
};
},
completion: {
title: 'Chapter complete',
text: 'You have completed this lesson. Restart to try it again, or continue to the next chapter.',
},
};
return lesson;
}

View file

@ -0,0 +1,138 @@
import { mount, unmount, tick } from 'svelte';
import { createTutorial, type TutorialMount, type TutorialSnapshot } from '@boardgamers/protocol/tutorial';
import { mountTutorialGuide } from '@boardgamers/protocol/tutorial/dom';
import { Controller } from '../controller';
import App from '../App.svelte';
import { loadTutorialEngine } from '../bridge';
import { mountLocalization } from '../localization';
import { createLesson, type Action, type State } from './lessons';
import gameCss from '../style.css?inline';
import tutorialCss from './tutorial.css?inline';
const positions = import.meta.glob('./positions/*.json', {
eager: true,
query: '?url&no-inline',
import: 'default',
}) as Record<string, string>;
export const mountTutorial: TutorialMount = async (target, options) => {
const url = positions[`./positions/${options.chapter}.json`];
if (!url) throw new Error(`Unknown Clash of Cultures chapter: ${options.chapter}`);
const response = await fetch(url, { signal: AbortSignal.timeout(20000) });
if (!response.ok) throw new Error(`Could not load tutorial position (HTTP ${response.status}).`);
const initialGame = JSON.stringify(await response.json());
const engine = await loadTutorialEngine();
const lesson = createLesson(options.chapter, engine, initialGame);
const localization = mountLocalization(target, options.locale);
await localization.ready;
const style = document.createElement('style');
style.textContent = gameCss + tutorialCss;
document.head.append(style);
const layout = document.createElement('div');
layout.className = 'clash-tutorial';
const sidebar = document.createElement('aside');
sidebar.className = 'tutorial-sidebar';
const guide = document.createElement('section');
const choices = document.createElement('div');
choices.className = 'tutorial-choices';
choices.setAttribute('aria-label', 'Lesson actions');
const board = document.createElement('div');
board.className = 'tutorial-board';
sidebar.append(guide, choices);
layout.append(sidebar, board);
target.append(layout);
let storage: Storage | undefined;
try {
storage = localStorage;
} catch {
/* Saving is optional. */
}
const tutorial = await createTutorial({ ...lesson, storage, onProgress: options.onProgress });
let latest: TutorialSnapshot<State> = tutorial.snapshot;
let destroyed = false;
let displayed: string | undefined;
let queue = Promise.resolve();
const send = async (action: Action) => {
if (destroyed || latest.busy || latest.completed) return;
const accepted = await tutorial.play(action);
if (!destroyed && !accepted)
controller.handleError(tutorial.snapshot.error || 'Follow the current lesson step.');
};
const preferences: Record<string, unknown> = {
locale: options.locale,
sound: false,
replayAutoplay: false,
};
const noop = () => false;
const controller = new Controller(
{
move: (move) => {
void send({ step: lesson.steps[latest.step].id, kind: 'move', move: JSON.parse(move) });
return true;
},
openPlayer: noop,
hoverPlayer: noop,
leavePlayer: noop,
openBoardgame: noop,
updateSetting: noop,
updatePreference: (name, value) => {
preferences[name] = value;
controller.setPreferences(preferences);
return true;
},
fetchState: () => {
void controller.load(engine.stripSecret(latest.state.game, 0));
return true;
},
fetchLog: noop,
addLog: () => true,
replaceLog: () => true,
setReplayInfo: () => true,
},
new URL('.', document.baseURI),
);
controller.setPlayer(0);
controller.setPreferences(preferences);
const app = mount(App, { target: board, props: { controller } });
const removeGuide = mountTutorialGuide(guide, tutorial, { nextChapter: options.nextChapter });
const remove = tutorial.subscribe((snapshot) => {
latest = snapshot;
choices.replaceChildren();
if (!snapshot.completed)
for (const offer of lesson.steps[snapshot.step].offers(snapshot.state)) {
const button = document.createElement('button');
button.type = 'button';
button.textContent = offer.label;
button.disabled = snapshot.busy;
button.onclick = () => void send(offer.action);
choices.append(button);
}
if (snapshot.state.game !== displayed) {
displayed = snapshot.state.game;
const raw = engine.stripSecret(snapshot.state.game, 0);
queue = queue
.then(async () => {
if (!destroyed) {
await controller.load(raw);
await tick();
localization.refresh();
}
})
.catch((error) => {
if (!destroyed) controller.handleError(error);
});
}
localization.refresh();
});
await queue;
return () => {
destroyed = true;
remove();
removeGuide();
tutorial.destroy();
controller.destroy();
localization.destroy();
void unmount(app);
style.remove();
layout.remove();
};
};

View file

@ -0,0 +1,814 @@
{
"version": 2,
"seed": "clash-tutorial-v1",
"state": "Playing",
"players": [
{
"id": 0,
"resources": {
"food": 2,
"wood": 3,
"ore": 3,
"ideas": 3,
"gold": 3,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D2",
"mood_state": "Neutral",
"activations": 1
},
{
"position": "E3",
"mood_state": "Angry"
}
],
"units": [
{
"position": "D2",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Rome",
"available_leaders": [
"Caesar",
"Augustus",
"Sulla"
],
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"action_cards": [
18
],
"objective_cards": [
4
],
"next_unit_id": 1,
"name": "You"
},
{
"id": 1,
"resources": {
"food": 2
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D7",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D7",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Persia",
"available_leaders": [
"Cyrus",
"Darius",
"Xerxes"
],
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"action_cards": [
24
],
"objective_cards": [
7
],
"next_unit_id": 1,
"name": "Opponent"
},
{
"id": 2,
"civilization": "Barbarians",
"next_unit_id": 0
},
{
"id": 3,
"civilization": "Pirates",
"next_unit_id": 0
}
],
"map": {
"tiles": [
[
"A3",
"Unexplored"
],
[
"A5",
"Unexplored"
],
[
"A7",
"Unexplored"
],
[
"B2",
"Unexplored"
],
[
"B3",
"Unexplored"
],
[
"B4",
"Unexplored"
],
[
"B5",
"Unexplored"
],
[
"B6",
"Unexplored"
],
[
"B7",
"Unexplored"
],
[
"C2",
"Forest"
],
[
"C3",
"Unexplored"
],
[
"C4",
"Unexplored"
],
[
"C5",
"Unexplored"
],
[
"C6",
"Unexplored"
],
[
"C7",
"Unexplored"
],
[
"C8",
"Mountain"
],
[
"D1",
"Water"
],
[
"D2",
"Fertile"
],
[
"D3",
"Unexplored"
],
[
"D4",
"Unexplored"
],
[
"D5",
"Unexplored"
],
[
"D6",
"Unexplored"
],
[
"D7",
"Fertile"
],
[
"D8",
"Barren"
],
[
"E2",
"Mountain"
],
[
"E3",
"Fertile"
],
[
"E4",
"Unexplored"
],
[
"E5",
"Unexplored"
],
[
"E6",
"Unexplored"
],
[
"E7",
"Unexplored"
],
[
"E8",
"Forest"
],
[
"F2",
"Unexplored"
],
[
"F3",
"Unexplored"
],
[
"F4",
"Unexplored"
],
[
"F5",
"Unexplored"
],
[
"F6",
"Unexplored"
],
[
"F7",
"Unexplored"
],
[
"G3",
"Unexplored"
],
[
"G5",
"Unexplored"
],
[
"G7",
"Unexplored"
]
],
"unexplored_blocks": [
{
"position": {
"top_tile": "B2",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Fertile",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "B4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Forest",
"Water",
"Fertile"
]
}
},
{
"position": {
"top_tile": "B6",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Barren",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D3",
"rotation": 0
},
"block": {
"terrain": [
"Forest",
"Mountain",
"Fertile",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D5",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Mountain",
"Forest",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F2",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "F4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Water",
"Mountain",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F6",
"rotation": 0
},
"block": {
"terrain": [
"Mountain",
"Water",
"Fertile",
"Mountain"
]
}
}
]
},
"starting_player_index": 0,
"current_player_index": 0,
"log": [
{
"age": 0,
"rounds": [
{
"round": 0,
"turns": [
{
"turn_type": {
"Setup": {
"player": 0,
"civilization": "Japan"
}
},
"actions": [
{
"action": "StartTurn",
"player": 0,
"items": [
{
"player": 0,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ActionCard": 18
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ObjectiveCard": 4
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D2",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"MoodChange": {
"city": "D2",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D2"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
},
{
"turn_type": {
"Setup": {
"player": 1,
"civilization": "Persia"
}
},
"actions": [
{
"action": "StartTurn",
"player": 1,
"items": [
{
"player": 1,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ActionCard": 24
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ObjectiveCard": 7
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D7",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"MoodChange": {
"city": "D7",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D7"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
}
]
}
]
},
{
"age": 1,
"rounds": [
{
"round": 1,
"turns": [
{
"turn_type": {
"Player": 0
}
}
]
}
]
}
],
"log_index": 0,
"undo_limit": 0,
"actions_left": 3,
"round": 1,
"age": 1,
"messages": [
"Age 1 has started"
],
"rng": "296445263143693867296281034113932097109",
"wonders_left": [
"Pyramids",
"GreatMausoleum",
"GreatLibrary",
"GreatStatue",
"GreatGardens",
"GreatLighthouse",
"Colosseum",
"GreatWall"
],
"action_cards_left": [
14,
10,
11,
3,
2,
37,
5,
20,
34,
4,
25,
21,
39,
22,
32,
8,
1,
26,
16,
23,
42,
6,
12,
33,
13,
36,
31,
15,
17,
9,
7,
30,
41,
28,
29,
38,
19,
27,
40,
35
],
"objective_cards_left": [
2,
9,
31,
19,
15,
27,
11,
29,
28,
18,
38,
13,
20,
10,
16,
1,
12,
21,
6,
36,
3,
33,
35,
30,
14,
37,
8,
22,
25,
32,
17,
23,
5,
26,
24,
34
],
"incidents_left": [
24,
48,
33,
1,
16,
15,
14,
58,
12,
2,
11,
13,
19,
25,
7,
55,
20,
45,
10,
8,
52,
42,
51,
40,
37,
35,
32,
47,
43,
46,
41,
36,
57,
49,
26,
17,
6,
18,
28,
4,
38,
44,
53,
5,
34,
21,
3,
50,
30,
9,
23,
56,
29,
39,
31,
27,
22,
54
]
}

View file

@ -0,0 +1,810 @@
{
"version": 2,
"seed": "clash-tutorial-v1",
"state": "Playing",
"players": [
{
"id": 0,
"resources": {
"food": 2,
"wood": 3,
"ore": 3,
"ideas": 3,
"gold": 3,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D2",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D2",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Rome",
"available_leaders": [
"Caesar",
"Augustus",
"Sulla"
],
"advances": [
"Farming",
"Mining",
"Tactics"
],
"incident_tokens": 3,
"action_cards": [
18
],
"objective_cards": [
4
],
"next_unit_id": 1,
"name": "You"
},
{
"id": 1,
"resources": {
"food": 2
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D7",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D7",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Persia",
"available_leaders": [
"Cyrus",
"Darius",
"Xerxes"
],
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"action_cards": [
24
],
"objective_cards": [
7
],
"next_unit_id": 1,
"name": "Opponent"
},
{
"id": 2,
"civilization": "Barbarians",
"next_unit_id": 0
},
{
"id": 3,
"civilization": "Pirates",
"next_unit_id": 0
}
],
"map": {
"tiles": [
[
"A3",
"Unexplored"
],
[
"A5",
"Unexplored"
],
[
"A7",
"Unexplored"
],
[
"B2",
"Unexplored"
],
[
"B3",
"Unexplored"
],
[
"B4",
"Unexplored"
],
[
"B5",
"Unexplored"
],
[
"B6",
"Unexplored"
],
[
"B7",
"Unexplored"
],
[
"C2",
"Forest"
],
[
"C3",
"Unexplored"
],
[
"C4",
"Unexplored"
],
[
"C5",
"Unexplored"
],
[
"C6",
"Unexplored"
],
[
"C7",
"Unexplored"
],
[
"C8",
"Mountain"
],
[
"D1",
"Water"
],
[
"D2",
"Fertile"
],
[
"D3",
"Unexplored"
],
[
"D4",
"Unexplored"
],
[
"D5",
"Unexplored"
],
[
"D6",
"Unexplored"
],
[
"D7",
"Fertile"
],
[
"D8",
"Barren"
],
[
"E2",
"Mountain"
],
[
"E3",
"Unexplored"
],
[
"E4",
"Unexplored"
],
[
"E5",
"Unexplored"
],
[
"E6",
"Unexplored"
],
[
"E7",
"Unexplored"
],
[
"E8",
"Forest"
],
[
"F2",
"Unexplored"
],
[
"F3",
"Unexplored"
],
[
"F4",
"Unexplored"
],
[
"F5",
"Unexplored"
],
[
"F6",
"Unexplored"
],
[
"F7",
"Unexplored"
],
[
"G3",
"Unexplored"
],
[
"G5",
"Unexplored"
],
[
"G7",
"Unexplored"
]
],
"unexplored_blocks": [
{
"position": {
"top_tile": "B2",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Fertile",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "B4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Forest",
"Water",
"Fertile"
]
}
},
{
"position": {
"top_tile": "B6",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Barren",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D3",
"rotation": 0
},
"block": {
"terrain": [
"Forest",
"Mountain",
"Fertile",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D5",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Mountain",
"Forest",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F2",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "F4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Water",
"Mountain",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F6",
"rotation": 0
},
"block": {
"terrain": [
"Mountain",
"Water",
"Fertile",
"Mountain"
]
}
}
]
},
"starting_player_index": 0,
"current_player_index": 0,
"log": [
{
"age": 0,
"rounds": [
{
"round": 0,
"turns": [
{
"turn_type": {
"Setup": {
"player": 0,
"civilization": "Japan"
}
},
"actions": [
{
"action": "StartTurn",
"player": 0,
"items": [
{
"player": 0,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ActionCard": 18
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ObjectiveCard": 4
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D2",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"MoodChange": {
"city": "D2",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D2"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
},
{
"turn_type": {
"Setup": {
"player": 1,
"civilization": "Persia"
}
},
"actions": [
{
"action": "StartTurn",
"player": 1,
"items": [
{
"player": 1,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ActionCard": 24
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ObjectiveCard": 7
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D7",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"MoodChange": {
"city": "D7",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D7"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
}
]
}
]
},
{
"age": 1,
"rounds": [
{
"round": 1,
"turns": [
{
"turn_type": {
"Player": 0
}
}
]
}
]
}
],
"log_index": 0,
"undo_limit": 0,
"actions_left": 3,
"round": 1,
"age": 1,
"messages": [
"Age 1 has started"
],
"rng": "296445263143693867296281034113932097109",
"wonders_left": [
"Pyramids",
"GreatMausoleum",
"GreatLibrary",
"GreatStatue",
"GreatGardens",
"GreatLighthouse",
"Colosseum",
"GreatWall"
],
"action_cards_left": [
14,
10,
11,
3,
2,
37,
5,
20,
34,
4,
25,
21,
39,
22,
32,
8,
1,
26,
16,
23,
42,
6,
12,
33,
13,
36,
31,
15,
17,
9,
7,
30,
41,
28,
29,
38,
19,
27,
40,
35
],
"objective_cards_left": [
2,
9,
31,
19,
15,
27,
11,
29,
28,
18,
38,
13,
20,
10,
16,
1,
12,
21,
6,
36,
3,
33,
35,
30,
14,
37,
8,
22,
25,
32,
17,
23,
5,
26,
24,
34
],
"incidents_left": [
24,
48,
33,
1,
16,
15,
14,
58,
12,
2,
11,
13,
19,
25,
7,
55,
20,
45,
10,
8,
52,
42,
51,
40,
37,
35,
32,
47,
43,
46,
41,
36,
57,
49,
26,
17,
6,
18,
28,
4,
38,
44,
53,
5,
34,
21,
3,
50,
30,
9,
23,
56,
29,
39,
31,
27,
22,
54
]
}

View file

@ -0,0 +1,817 @@
{
"version": 2,
"seed": "clash-tutorial-v1",
"state": "Playing",
"players": [
{
"id": 0,
"resources": {
"food": 2,
"wood": 3,
"ore": 3,
"ideas": 3,
"gold": 3,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D2",
"mood_state": "Happy",
"city_pieces": {
"temple": 0
}
},
{
"position": "E3",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D2",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Rome",
"available_leaders": [
"Caesar",
"Augustus",
"Sulla"
],
"advances": [
"Farming",
"Mining",
"Myths"
],
"incident_tokens": 3,
"action_cards": [
18
],
"objective_cards": [
4
],
"next_unit_id": 1,
"name": "You"
},
{
"id": 1,
"resources": {
"food": 2
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D7",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D7",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Persia",
"available_leaders": [
"Cyrus",
"Darius",
"Xerxes"
],
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"action_cards": [
24
],
"objective_cards": [
7
],
"next_unit_id": 1,
"name": "Opponent"
},
{
"id": 2,
"civilization": "Barbarians",
"next_unit_id": 0
},
{
"id": 3,
"civilization": "Pirates",
"next_unit_id": 0
}
],
"map": {
"tiles": [
[
"A3",
"Unexplored"
],
[
"A5",
"Unexplored"
],
[
"A7",
"Unexplored"
],
[
"B2",
"Unexplored"
],
[
"B3",
"Unexplored"
],
[
"B4",
"Unexplored"
],
[
"B5",
"Unexplored"
],
[
"B6",
"Unexplored"
],
[
"B7",
"Unexplored"
],
[
"C2",
"Forest"
],
[
"C3",
"Unexplored"
],
[
"C4",
"Unexplored"
],
[
"C5",
"Unexplored"
],
[
"C6",
"Unexplored"
],
[
"C7",
"Unexplored"
],
[
"C8",
"Mountain"
],
[
"D1",
"Water"
],
[
"D2",
"Fertile"
],
[
"D3",
"Unexplored"
],
[
"D4",
"Unexplored"
],
[
"D5",
"Unexplored"
],
[
"D6",
"Unexplored"
],
[
"D7",
"Fertile"
],
[
"D8",
"Barren"
],
[
"E2",
"Mountain"
],
[
"E3",
"Fertile"
],
[
"E4",
"Unexplored"
],
[
"E5",
"Unexplored"
],
[
"E6",
"Unexplored"
],
[
"E7",
"Unexplored"
],
[
"E8",
"Forest"
],
[
"F2",
"Unexplored"
],
[
"F3",
"Unexplored"
],
[
"F4",
"Unexplored"
],
[
"F5",
"Unexplored"
],
[
"F6",
"Unexplored"
],
[
"F7",
"Unexplored"
],
[
"G3",
"Unexplored"
],
[
"G5",
"Unexplored"
],
[
"G7",
"Unexplored"
]
],
"unexplored_blocks": [
{
"position": {
"top_tile": "B2",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Fertile",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "B4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Forest",
"Water",
"Fertile"
]
}
},
{
"position": {
"top_tile": "B6",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Barren",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D3",
"rotation": 0
},
"block": {
"terrain": [
"Forest",
"Mountain",
"Fertile",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D5",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Mountain",
"Forest",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F2",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "F4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Water",
"Mountain",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F6",
"rotation": 0
},
"block": {
"terrain": [
"Mountain",
"Water",
"Fertile",
"Mountain"
]
}
}
]
},
"starting_player_index": 0,
"current_player_index": 0,
"log": [
{
"age": 0,
"rounds": [
{
"round": 0,
"turns": [
{
"turn_type": {
"Setup": {
"player": 0,
"civilization": "Japan"
}
},
"actions": [
{
"action": "StartTurn",
"player": 0,
"items": [
{
"player": 0,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ActionCard": 18
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ObjectiveCard": 4
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D2",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"MoodChange": {
"city": "D2",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D2"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
},
{
"turn_type": {
"Setup": {
"player": 1,
"civilization": "Persia"
}
},
"actions": [
{
"action": "StartTurn",
"player": 1,
"items": [
{
"player": 1,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ActionCard": 24
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ObjectiveCard": 7
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D7",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"MoodChange": {
"city": "D7",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D7"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
}
]
}
]
},
{
"age": 1,
"rounds": [
{
"round": 1,
"turns": [
{
"turn_type": {
"Player": 0
}
}
]
}
]
}
],
"log_index": 0,
"undo_limit": 0,
"actions_left": 3,
"round": 1,
"age": 1,
"messages": [
"Age 1 has started"
],
"rng": "296445263143693867296281034113932097109",
"wonders_left": [
"Pyramids",
"GreatMausoleum",
"GreatLibrary",
"GreatStatue",
"GreatGardens",
"GreatLighthouse",
"Colosseum",
"GreatWall"
],
"action_cards_left": [
14,
10,
11,
3,
2,
37,
5,
20,
34,
4,
25,
21,
39,
22,
32,
8,
1,
26,
16,
23,
42,
6,
12,
33,
13,
36,
31,
15,
17,
9,
7,
30,
41,
28,
29,
38,
19,
27,
40,
35
],
"objective_cards_left": [
2,
9,
31,
19,
15,
27,
11,
29,
28,
18,
38,
13,
20,
10,
16,
1,
12,
21,
6,
36,
3,
33,
35,
30,
14,
37,
8,
22,
25,
32,
17,
23,
5,
26,
24,
34
],
"incidents_left": [
24,
48,
33,
1,
16,
15,
14,
58,
12,
2,
11,
13,
19,
25,
7,
55,
20,
45,
10,
8,
52,
42,
51,
40,
37,
35,
32,
47,
43,
46,
41,
36,
57,
49,
26,
17,
6,
18,
28,
4,
38,
44,
53,
5,
34,
21,
3,
50,
30,
9,
23,
56,
29,
39,
31,
27,
22,
54
]
}

View file

@ -0,0 +1,223 @@
{
"state": "Playing",
"players": [
{
"id": 0,
"resources": {
"food": 1,
"wood": 6,
"ore": 6,
"ideas": 5,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"cities": [
{
"position": "A1",
"mood_state": "Happy"
}
],
"units": [
{
"position": "C2",
"unit_type": "Infantry",
"id": 0
},
{
"position": "C2",
"unit_type": "Cavalry",
"id": 1
},
{
"position": "C2",
"unit_type": "Infantry",
"id": 2
},
{
"position": "C2",
"unit_type": "Elephant",
"id": 3
},
{
"position": "C2",
"unit_type": "Settler",
"id": 4
},
{
"position": "C2",
"unit_type": "Settler",
"id": 5
},
{
"position": "C2",
"unit_type": "Settler",
"id": 6
},
{
"position": "C2",
"unit_type": "Settler",
"id": 7
}
],
"civilization": "Rome",
"advances": [
"Farming",
"Mining",
"Tactics"
],
"incident_tokens": 2,
"next_unit_id": 8
},
{
"id": 1,
"resources": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"cities": [
{
"mood_state": "Angry",
"activations": 2,
"position": "C1",
"city_pieces": {
"temple": 1
}
}
],
"units": [
{
"position": "C1",
"unit_type": "Infantry",
"id": 0
},
{
"position": "C1",
"unit_type": "Infantry",
"id": 1
}
],
"civilization": "Greece",
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"next_unit_id": 2
},
{
"id": 2,
"civilization": "Barbarians",
"next_unit_id": 0,
"cities": [],
"units": []
},
{
"id": 3,
"civilization": "Pirates",
"next_unit_id": 0,
"cities": [],
"units": []
}
],
"map": {
"tiles": [
[
"A1",
"Fertile"
],
[
"A2",
"Water"
],
[
"A3",
"Mountain"
],
[
"B1",
"Mountain"
],
[
"B2",
"Forest"
],
[
"B3",
"Fertile"
],
[
"C1",
"Barren"
],
[
"C2",
"Forest"
],
[
"C3",
"Water"
],
[
"D2",
"Water"
]
]
},
"starting_player_index": 0,
"current_player_index": 0,
"log": [
{
"age": 1,
"rounds": [
{
"round": 1,
"turns": [
{
"turn_type": {
"Player": 0
}
}
]
}
]
}
],
"log_index": 0,
"undo_limit": 0,
"actions_left": 3,
"round": 1,
"age": 1,
"messages": [
"The game has started"
],
"dice_roll_outcomes": [
0
],
"wonders_left": [
"Pyramids"
]
}

View file

@ -0,0 +1,809 @@
{
"version": 2,
"seed": "clash-tutorial-v1",
"state": "Playing",
"players": [
{
"id": 0,
"resources": {
"food": 2,
"wood": 3,
"ore": 3,
"ideas": 3,
"gold": 3,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D2",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D2",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Rome",
"available_leaders": [
"Caesar",
"Augustus",
"Sulla"
],
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"action_cards": [
18
],
"objective_cards": [
4
],
"next_unit_id": 1,
"name": "You"
},
{
"id": 1,
"resources": {
"food": 2
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D7",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D7",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Persia",
"available_leaders": [
"Cyrus",
"Darius",
"Xerxes"
],
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"action_cards": [
24
],
"objective_cards": [
7
],
"next_unit_id": 1,
"name": "Opponent"
},
{
"id": 2,
"civilization": "Barbarians",
"next_unit_id": 0
},
{
"id": 3,
"civilization": "Pirates",
"next_unit_id": 0
}
],
"map": {
"tiles": [
[
"A3",
"Unexplored"
],
[
"A5",
"Unexplored"
],
[
"A7",
"Unexplored"
],
[
"B2",
"Unexplored"
],
[
"B3",
"Unexplored"
],
[
"B4",
"Unexplored"
],
[
"B5",
"Unexplored"
],
[
"B6",
"Unexplored"
],
[
"B7",
"Unexplored"
],
[
"C2",
"Forest"
],
[
"C3",
"Unexplored"
],
[
"C4",
"Unexplored"
],
[
"C5",
"Unexplored"
],
[
"C6",
"Unexplored"
],
[
"C7",
"Unexplored"
],
[
"C8",
"Mountain"
],
[
"D1",
"Water"
],
[
"D2",
"Fertile"
],
[
"D3",
"Unexplored"
],
[
"D4",
"Unexplored"
],
[
"D5",
"Unexplored"
],
[
"D6",
"Unexplored"
],
[
"D7",
"Fertile"
],
[
"D8",
"Barren"
],
[
"E2",
"Mountain"
],
[
"E3",
"Unexplored"
],
[
"E4",
"Unexplored"
],
[
"E5",
"Unexplored"
],
[
"E6",
"Unexplored"
],
[
"E7",
"Unexplored"
],
[
"E8",
"Forest"
],
[
"F2",
"Unexplored"
],
[
"F3",
"Unexplored"
],
[
"F4",
"Unexplored"
],
[
"F5",
"Unexplored"
],
[
"F6",
"Unexplored"
],
[
"F7",
"Unexplored"
],
[
"G3",
"Unexplored"
],
[
"G5",
"Unexplored"
],
[
"G7",
"Unexplored"
]
],
"unexplored_blocks": [
{
"position": {
"top_tile": "B2",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Fertile",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "B4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Forest",
"Water",
"Fertile"
]
}
},
{
"position": {
"top_tile": "B6",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Barren",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D3",
"rotation": 0
},
"block": {
"terrain": [
"Forest",
"Mountain",
"Fertile",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D5",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Mountain",
"Forest",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F2",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "F4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Water",
"Mountain",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F6",
"rotation": 0
},
"block": {
"terrain": [
"Mountain",
"Water",
"Fertile",
"Mountain"
]
}
}
]
},
"starting_player_index": 0,
"current_player_index": 0,
"log": [
{
"age": 0,
"rounds": [
{
"round": 0,
"turns": [
{
"turn_type": {
"Setup": {
"player": 0,
"civilization": "Japan"
}
},
"actions": [
{
"action": "StartTurn",
"player": 0,
"items": [
{
"player": 0,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ActionCard": 18
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ObjectiveCard": 4
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D2",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"MoodChange": {
"city": "D2",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D2"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
},
{
"turn_type": {
"Setup": {
"player": 1,
"civilization": "Persia"
}
},
"actions": [
{
"action": "StartTurn",
"player": 1,
"items": [
{
"player": 1,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ActionCard": 24
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ObjectiveCard": 7
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D7",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"MoodChange": {
"city": "D7",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D7"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
}
]
}
]
},
{
"age": 1,
"rounds": [
{
"round": 1,
"turns": [
{
"turn_type": {
"Player": 0
}
}
]
}
]
}
],
"log_index": 0,
"undo_limit": 0,
"actions_left": 3,
"round": 1,
"age": 1,
"messages": [
"Age 1 has started"
],
"rng": "296445263143693867296281034113932097109",
"wonders_left": [
"Pyramids",
"GreatMausoleum",
"GreatLibrary",
"GreatStatue",
"GreatGardens",
"GreatLighthouse",
"Colosseum",
"GreatWall"
],
"action_cards_left": [
14,
10,
11,
3,
2,
37,
5,
20,
34,
4,
25,
21,
39,
22,
32,
8,
1,
26,
16,
23,
42,
6,
12,
33,
13,
36,
31,
15,
17,
9,
7,
30,
41,
28,
29,
38,
19,
27,
40,
35
],
"objective_cards_left": [
2,
9,
31,
19,
15,
27,
11,
29,
28,
18,
38,
13,
20,
10,
16,
1,
12,
21,
6,
36,
3,
33,
35,
30,
14,
37,
8,
22,
25,
32,
17,
23,
5,
26,
24,
34
],
"incidents_left": [
24,
48,
33,
1,
16,
15,
14,
58,
12,
2,
11,
13,
19,
25,
7,
55,
20,
45,
10,
8,
52,
42,
51,
40,
37,
35,
32,
47,
43,
46,
41,
36,
57,
49,
26,
17,
6,
18,
28,
4,
38,
44,
53,
5,
34,
21,
3,
50,
30,
9,
23,
56,
29,
39,
31,
27,
22,
54
]
}

View file

@ -0,0 +1,265 @@
{
"state": "Playing",
"players": [
{
"id": 0,
"resources": {
"food": 1,
"wood": 6,
"ore": 6,
"ideas": 5,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"cities": [
{
"city_pieces": {
"fortress": 0,
"temple": 1,
"wonders": [
"Pyramids"
]
},
"mood_state": "Happy",
"position": "C2"
},
{
"mood_state": "Happy",
"position": "C1"
},
{
"mood_state": "Happy",
"position": "B2"
},
{
"mood_state": "Happy",
"position": "B3"
}
],
"units": [
{
"position": "C2",
"unit_type": "Infantry",
"id": 0
},
{
"position": "C2",
"unit_type": "Cavalry",
"id": 1
},
{
"position": "C2",
"unit_type": "Infantry",
"id": 2
},
{
"position": "C2",
"unit_type": "Elephant",
"id": 3
},
{
"position": "C2",
"unit_type": "Settler",
"id": 4
},
{
"position": "C2",
"unit_type": "Settler",
"id": 5
},
{
"position": "C2",
"unit_type": "Settler",
"id": 6
},
{
"position": "C2",
"unit_type": "Settler",
"id": 7
}
],
"civilization": "Rome",
"advances": [
"Farming",
"Mining",
"Tactics",
"Myths"
],
"wonders_built": [
"Pyramids"
],
"incident_tokens": 1,
"next_unit_id": 8
},
{
"id": 1,
"resources": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"cities": [
{
"city_pieces": {
"fortress": 0
},
"mood_state": "Happy",
"position": "A1"
},
{
"mood_state": "Happy",
"position": "A3"
},
{
"city_pieces": {
"fortress": 0
},
"mood_state": "Happy",
"position": "A4"
}
],
"civilization": "Greece",
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"next_unit_id": 2
},
{
"id": 2,
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"civilization": "Barbarians",
"incident_tokens": 3,
"next_unit_id": 0
},
{
"id": 3,
"civilization": "Pirates",
"next_unit_id": 0,
"cities": [],
"units": []
}
],
"map": {
"tiles": [
[
"A1",
"Fertile"
],
[
"A2",
"Water"
],
[
"A3",
"Mountain"
],
[
"A4",
"Mountain"
],
[
"B1",
"Mountain"
],
[
"B2",
"Forest"
],
[
"B3",
"Fertile"
],
[
"C1",
"Barren"
],
[
"C2",
"Forest"
],
[
"C3",
"Water"
],
[
"D2",
"Water"
]
]
},
"starting_player_index": 0,
"current_player_index": 0,
"log": [
{
"age": 1,
"rounds": [
{
"round": 1,
"turns": [
{
"turn_type": {
"Player": 0
}
}
]
}
]
}
],
"log_index": 0,
"undo_limit": 0,
"actions_left": 3,
"round": 1,
"age": 1,
"messages": [
"The game has started"
],
"dice_roll_outcomes": [
1,
1,
10,
10,
10,
10,
10,
10,
10
],
"dice_roll_log": [
10
],
"incidents_left": [
33
]
}

View file

@ -0,0 +1,814 @@
{
"version": 2,
"seed": "clash-tutorial-v1",
"state": "Playing",
"players": [
{
"id": 0,
"resources": {
"food": 2,
"wood": 3,
"ore": 3,
"ideas": 3,
"gold": 3,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D2",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D2",
"unit_type": "Settler",
"id": 0
},
{
"id": 1,
"position": "D2",
"unit_type": "Settler"
}
],
"civilization": "Rome",
"available_leaders": [
"Caesar",
"Augustus",
"Sulla"
],
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"action_cards": [
18
],
"objective_cards": [
4
],
"next_unit_id": 2,
"name": "You"
},
{
"id": 1,
"resources": {
"food": 2
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D7",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D7",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Persia",
"available_leaders": [
"Cyrus",
"Darius",
"Xerxes"
],
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"action_cards": [
24
],
"objective_cards": [
7
],
"next_unit_id": 1,
"name": "Opponent"
},
{
"id": 2,
"civilization": "Barbarians",
"next_unit_id": 0
},
{
"id": 3,
"civilization": "Pirates",
"next_unit_id": 0
}
],
"map": {
"tiles": [
[
"A3",
"Unexplored"
],
[
"A5",
"Unexplored"
],
[
"A7",
"Unexplored"
],
[
"B2",
"Unexplored"
],
[
"B3",
"Unexplored"
],
[
"B4",
"Unexplored"
],
[
"B5",
"Unexplored"
],
[
"B6",
"Unexplored"
],
[
"B7",
"Unexplored"
],
[
"C2",
"Forest"
],
[
"C3",
"Unexplored"
],
[
"C4",
"Unexplored"
],
[
"C5",
"Unexplored"
],
[
"C6",
"Unexplored"
],
[
"C7",
"Unexplored"
],
[
"C8",
"Mountain"
],
[
"D1",
"Water"
],
[
"D2",
"Fertile"
],
[
"D3",
"Unexplored"
],
[
"D4",
"Unexplored"
],
[
"D5",
"Unexplored"
],
[
"D6",
"Unexplored"
],
[
"D7",
"Fertile"
],
[
"D8",
"Barren"
],
[
"E2",
"Mountain"
],
[
"E3",
"Unexplored"
],
[
"E4",
"Unexplored"
],
[
"E5",
"Unexplored"
],
[
"E6",
"Unexplored"
],
[
"E7",
"Unexplored"
],
[
"E8",
"Forest"
],
[
"F2",
"Unexplored"
],
[
"F3",
"Unexplored"
],
[
"F4",
"Unexplored"
],
[
"F5",
"Unexplored"
],
[
"F6",
"Unexplored"
],
[
"F7",
"Unexplored"
],
[
"G3",
"Unexplored"
],
[
"G5",
"Unexplored"
],
[
"G7",
"Unexplored"
]
],
"unexplored_blocks": [
{
"position": {
"top_tile": "B2",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Fertile",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "B4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Forest",
"Water",
"Fertile"
]
}
},
{
"position": {
"top_tile": "B6",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Barren",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D3",
"rotation": 0
},
"block": {
"terrain": [
"Forest",
"Mountain",
"Fertile",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D5",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Mountain",
"Forest",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F2",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "F4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Water",
"Mountain",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F6",
"rotation": 0
},
"block": {
"terrain": [
"Mountain",
"Water",
"Fertile",
"Mountain"
]
}
}
]
},
"starting_player_index": 0,
"current_player_index": 0,
"log": [
{
"age": 0,
"rounds": [
{
"round": 0,
"turns": [
{
"turn_type": {
"Setup": {
"player": 0,
"civilization": "Japan"
}
},
"actions": [
{
"action": "StartTurn",
"player": 0,
"items": [
{
"player": 0,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ActionCard": 18
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ObjectiveCard": 4
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D2",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"MoodChange": {
"city": "D2",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D2"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
},
{
"turn_type": {
"Setup": {
"player": 1,
"civilization": "Persia"
}
},
"actions": [
{
"action": "StartTurn",
"player": 1,
"items": [
{
"player": 1,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ActionCard": 24
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ObjectiveCard": 7
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D7",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"MoodChange": {
"city": "D7",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D7"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
}
]
}
]
},
{
"age": 1,
"rounds": [
{
"round": 1,
"turns": [
{
"turn_type": {
"Player": 0
}
}
]
}
]
}
],
"log_index": 0,
"undo_limit": 0,
"actions_left": 3,
"round": 1,
"age": 1,
"messages": [
"Age 1 has started"
],
"rng": "296445263143693867296281034113932097109",
"wonders_left": [
"Pyramids",
"GreatMausoleum",
"GreatLibrary",
"GreatStatue",
"GreatGardens",
"GreatLighthouse",
"Colosseum",
"GreatWall"
],
"action_cards_left": [
14,
10,
11,
3,
2,
37,
5,
20,
34,
4,
25,
21,
39,
22,
32,
8,
1,
26,
16,
23,
42,
6,
12,
33,
13,
36,
31,
15,
17,
9,
7,
30,
41,
28,
29,
38,
19,
27,
40,
35
],
"objective_cards_left": [
2,
9,
31,
19,
15,
27,
11,
29,
28,
18,
38,
13,
20,
10,
16,
1,
12,
21,
6,
36,
3,
33,
35,
30,
14,
37,
8,
22,
25,
32,
17,
23,
5,
26,
24,
34
],
"incidents_left": [
24,
48,
33,
1,
16,
15,
14,
58,
12,
2,
11,
13,
19,
25,
7,
55,
20,
45,
10,
8,
52,
42,
51,
40,
37,
35,
32,
47,
43,
46,
41,
36,
57,
49,
26,
17,
6,
18,
28,
4,
38,
44,
53,
5,
34,
21,
3,
50,
30,
9,
23,
56,
29,
39,
31,
27,
22,
54
]
}

View file

@ -0,0 +1,247 @@
{
"state": "Playing",
"players": [
{
"id": 0,
"resources": {
"food": 1,
"wood": 7,
"ore": 7,
"ideas": 5,
"gold": 7,
"mood_tokens": 6,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"cities": [
{
"mood_state": "Happy",
"position": "A1"
},
{
"city_pieces": {
"observatory": 0
},
"mood_state": "Neutral",
"activations": 1,
"position": "C2"
}
],
"units": [
{
"position": "C2",
"unit_type": "Infantry",
"id": 0
},
{
"position": "C2",
"unit_type": "Cavalry",
"id": 1
},
{
"position": "C2",
"unit_type": "Infantry",
"id": 2
},
{
"position": "C2",
"unit_type": "Elephant",
"id": 3
},
{
"position": "C2",
"unit_type": "Settler",
"id": 4
},
{
"position": "C2",
"unit_type": "Settler",
"id": 5
},
{
"position": "C2",
"unit_type": "Settler",
"id": 6
},
{
"position": "C2",
"unit_type": "Settler",
"id": 7
},
{
"position": "A1",
"unit_type": "Infantry",
"id": 9
}
],
"civilization": "Rome",
"advances": [
"Draft",
"Farming",
"Math",
"Mining"
],
"incident_tokens": 2,
"objective_cards": [
1
],
"next_unit_id": 10
},
{
"id": 1,
"resources": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7,
"mood_tokens": 7,
"culture_tokens": 7
},
"cities": [
{
"mood_state": "Angry",
"position": "C1"
}
],
"units": [
{
"position": "C1",
"unit_type": "Infantry",
"id": 0
},
{
"position": "C1",
"unit_type": "Infantry",
"id": 1
}
],
"civilization": "Greece",
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"next_unit_id": 2
},
{
"id": 2,
"civilization": "Barbarians",
"next_unit_id": 0,
"cities": [],
"units": []
},
{
"id": 3,
"civilization": "Pirates",
"next_unit_id": 0,
"cities": [],
"units": []
}
],
"map": {
"tiles": [
[
"A1",
"Fertile"
],
[
"A2",
"Water"
],
[
"A3",
{
"Exhausted": "Forest"
}
],
[
"B1",
"Mountain"
],
[
"B2",
"Forest"
],
[
"B3",
"Fertile"
],
[
"C1",
"Barren"
],
[
"C2",
"Forest"
],
[
"C3",
"Water"
],
[
"D2",
"Water"
]
]
},
"starting_player_index": 0,
"current_player_index": 0,
"log": [
{
"age": 1,
"rounds": [
{
"round": 1,
"turns": [
{
"turn_type": {
"Player": 0
}
}
]
}
]
}
],
"log_index": 0,
"undo_limit": 0,
"actions_left": 2,
"round": 2,
"age": 1,
"messages": [
"The game has started"
],
"dice_roll_outcomes": [
1,
1,
10,
10,
10,
10,
10,
10,
10,
10
],
"wonders_left": [
"Pyramids"
]
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,810 @@
{
"version": 2,
"seed": "clash-tutorial-v1",
"state": "Playing",
"players": [
{
"id": 0,
"resources": {
"food": 2,
"wood": 3,
"ore": 3,
"ideas": 3,
"gold": 3,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D2",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D2",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Rome",
"available_leaders": [
"Caesar",
"Augustus",
"Sulla"
],
"advances": [
"Farming",
"Mining",
"Writing"
],
"incident_tokens": 3,
"action_cards": [
18
],
"objective_cards": [
4
],
"next_unit_id": 1,
"name": "You"
},
{
"id": 1,
"resources": {
"food": 2
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D7",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D7",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Persia",
"available_leaders": [
"Cyrus",
"Darius",
"Xerxes"
],
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"action_cards": [
24
],
"objective_cards": [
7
],
"next_unit_id": 1,
"name": "Opponent"
},
{
"id": 2,
"civilization": "Barbarians",
"next_unit_id": 0
},
{
"id": 3,
"civilization": "Pirates",
"next_unit_id": 0
}
],
"map": {
"tiles": [
[
"A3",
"Unexplored"
],
[
"A5",
"Unexplored"
],
[
"A7",
"Unexplored"
],
[
"B2",
"Unexplored"
],
[
"B3",
"Unexplored"
],
[
"B4",
"Unexplored"
],
[
"B5",
"Unexplored"
],
[
"B6",
"Unexplored"
],
[
"B7",
"Unexplored"
],
[
"C2",
"Forest"
],
[
"C3",
"Unexplored"
],
[
"C4",
"Unexplored"
],
[
"C5",
"Unexplored"
],
[
"C6",
"Unexplored"
],
[
"C7",
"Unexplored"
],
[
"C8",
"Mountain"
],
[
"D1",
"Water"
],
[
"D2",
"Fertile"
],
[
"D3",
"Unexplored"
],
[
"D4",
"Unexplored"
],
[
"D5",
"Unexplored"
],
[
"D6",
"Unexplored"
],
[
"D7",
"Fertile"
],
[
"D8",
"Barren"
],
[
"E2",
"Mountain"
],
[
"E3",
"Unexplored"
],
[
"E4",
"Unexplored"
],
[
"E5",
"Unexplored"
],
[
"E6",
"Unexplored"
],
[
"E7",
"Unexplored"
],
[
"E8",
"Forest"
],
[
"F2",
"Unexplored"
],
[
"F3",
"Unexplored"
],
[
"F4",
"Unexplored"
],
[
"F5",
"Unexplored"
],
[
"F6",
"Unexplored"
],
[
"F7",
"Unexplored"
],
[
"G3",
"Unexplored"
],
[
"G5",
"Unexplored"
],
[
"G7",
"Unexplored"
]
],
"unexplored_blocks": [
{
"position": {
"top_tile": "B2",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Fertile",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "B4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Forest",
"Water",
"Fertile"
]
}
},
{
"position": {
"top_tile": "B6",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Barren",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D3",
"rotation": 0
},
"block": {
"terrain": [
"Forest",
"Mountain",
"Fertile",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D5",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Mountain",
"Forest",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F2",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "F4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Water",
"Mountain",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F6",
"rotation": 0
},
"block": {
"terrain": [
"Mountain",
"Water",
"Fertile",
"Mountain"
]
}
}
]
},
"starting_player_index": 0,
"current_player_index": 0,
"log": [
{
"age": 0,
"rounds": [
{
"round": 0,
"turns": [
{
"turn_type": {
"Setup": {
"player": 0,
"civilization": "Japan"
}
},
"actions": [
{
"action": "StartTurn",
"player": 0,
"items": [
{
"player": 0,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ActionCard": 18
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ObjectiveCard": 4
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D2",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"MoodChange": {
"city": "D2",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D2"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
},
{
"turn_type": {
"Setup": {
"player": 1,
"civilization": "Persia"
}
},
"actions": [
{
"action": "StartTurn",
"player": 1,
"items": [
{
"player": 1,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ActionCard": 24
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ObjectiveCard": 7
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D7",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"MoodChange": {
"city": "D7",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D7"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
}
]
}
]
},
{
"age": 1,
"rounds": [
{
"round": 1,
"turns": [
{
"turn_type": {
"Player": 0
}
}
]
}
]
}
],
"log_index": 0,
"undo_limit": 0,
"actions_left": 3,
"round": 1,
"age": 1,
"messages": [
"Age 1 has started"
],
"rng": "296445263143693867296281034113932097109",
"wonders_left": [
"Pyramids",
"GreatMausoleum",
"GreatLibrary",
"GreatStatue",
"GreatGardens",
"GreatLighthouse",
"Colosseum",
"GreatWall"
],
"action_cards_left": [
14,
10,
11,
3,
2,
37,
5,
20,
34,
4,
25,
21,
39,
22,
32,
8,
1,
26,
16,
23,
42,
6,
12,
33,
13,
36,
31,
15,
17,
9,
7,
30,
41,
28,
29,
38,
19,
27,
40,
35
],
"objective_cards_left": [
2,
9,
31,
19,
15,
27,
11,
29,
28,
18,
38,
13,
20,
10,
16,
1,
12,
21,
6,
36,
3,
33,
35,
30,
14,
37,
8,
22,
25,
32,
17,
23,
5,
26,
24,
34
],
"incidents_left": [
24,
48,
33,
1,
16,
15,
14,
58,
12,
2,
11,
13,
19,
25,
7,
55,
20,
45,
10,
8,
52,
42,
51,
40,
37,
35,
32,
47,
43,
46,
41,
36,
57,
49,
26,
17,
6,
18,
28,
4,
38,
44,
53,
5,
34,
21,
3,
50,
30,
9,
23,
56,
29,
39,
31,
27,
22,
54
]
}

View file

@ -0,0 +1,816 @@
{
"version": 2,
"seed": "clash-tutorial-v1",
"state": "Playing",
"players": [
{
"id": 0,
"resources": {
"food": 2,
"wood": 3,
"ore": 3,
"ideas": 3,
"gold": 3,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D2",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D2",
"unit_type": "Settler",
"id": 0
},
{
"id": 1,
"position": "D1",
"unit_type": "Ship"
}
],
"civilization": "Rome",
"available_leaders": [
"Caesar",
"Augustus",
"Sulla"
],
"advances": [
"Farming",
"Mining",
"Fishing",
"Tactics"
],
"incident_tokens": 3,
"action_cards": [
18
],
"objective_cards": [
4
],
"next_unit_id": 2,
"name": "You"
},
{
"id": 1,
"resources": {
"food": 2
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D7",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D7",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Persia",
"available_leaders": [
"Cyrus",
"Darius",
"Xerxes"
],
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"action_cards": [
24
],
"objective_cards": [
7
],
"next_unit_id": 1,
"name": "Opponent"
},
{
"id": 2,
"civilization": "Barbarians",
"next_unit_id": 0
},
{
"id": 3,
"civilization": "Pirates",
"next_unit_id": 0
}
],
"map": {
"tiles": [
[
"A3",
"Unexplored"
],
[
"A5",
"Unexplored"
],
[
"A7",
"Unexplored"
],
[
"B2",
"Unexplored"
],
[
"B3",
"Unexplored"
],
[
"B4",
"Unexplored"
],
[
"B5",
"Unexplored"
],
[
"B6",
"Unexplored"
],
[
"B7",
"Unexplored"
],
[
"C2",
"Water"
],
[
"C3",
"Water"
],
[
"C4",
"Unexplored"
],
[
"C5",
"Unexplored"
],
[
"C6",
"Unexplored"
],
[
"C7",
"Unexplored"
],
[
"C8",
"Mountain"
],
[
"D1",
"Water"
],
[
"D2",
"Fertile"
],
[
"D3",
"Water"
],
[
"D4",
"Unexplored"
],
[
"D5",
"Unexplored"
],
[
"D6",
"Unexplored"
],
[
"D7",
"Fertile"
],
[
"D8",
"Barren"
],
[
"E2",
"Mountain"
],
[
"E3",
"Fertile"
],
[
"E4",
"Unexplored"
],
[
"E5",
"Unexplored"
],
[
"E6",
"Unexplored"
],
[
"E7",
"Unexplored"
],
[
"E8",
"Forest"
],
[
"F2",
"Unexplored"
],
[
"F3",
"Unexplored"
],
[
"F4",
"Unexplored"
],
[
"F5",
"Unexplored"
],
[
"F6",
"Unexplored"
],
[
"F7",
"Unexplored"
],
[
"G3",
"Unexplored"
],
[
"G5",
"Unexplored"
],
[
"G7",
"Unexplored"
]
],
"unexplored_blocks": [
{
"position": {
"top_tile": "B2",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Fertile",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "B4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Forest",
"Water",
"Fertile"
]
}
},
{
"position": {
"top_tile": "B6",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Barren",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D3",
"rotation": 0
},
"block": {
"terrain": [
"Forest",
"Mountain",
"Fertile",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D5",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Mountain",
"Forest",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F2",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "F4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Water",
"Mountain",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F6",
"rotation": 0
},
"block": {
"terrain": [
"Mountain",
"Water",
"Fertile",
"Mountain"
]
}
}
]
},
"starting_player_index": 0,
"current_player_index": 0,
"log": [
{
"age": 0,
"rounds": [
{
"round": 0,
"turns": [
{
"turn_type": {
"Setup": {
"player": 0,
"civilization": "Japan"
}
},
"actions": [
{
"action": "StartTurn",
"player": 0,
"items": [
{
"player": 0,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ActionCard": 18
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ObjectiveCard": 4
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D2",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"MoodChange": {
"city": "D2",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D2"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
},
{
"turn_type": {
"Setup": {
"player": 1,
"civilization": "Persia"
}
},
"actions": [
{
"action": "StartTurn",
"player": 1,
"items": [
{
"player": 1,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ActionCard": 24
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ObjectiveCard": 7
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D7",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"MoodChange": {
"city": "D7",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D7"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
}
]
}
]
},
{
"age": 1,
"rounds": [
{
"round": 1,
"turns": [
{
"turn_type": {
"Player": 0
}
}
]
}
]
}
],
"log_index": 0,
"undo_limit": 0,
"actions_left": 3,
"round": 1,
"age": 1,
"messages": [
"Age 1 has started"
],
"rng": "296445263143693867296281034113932097109",
"wonders_left": [
"Pyramids",
"GreatMausoleum",
"GreatLibrary",
"GreatStatue",
"GreatGardens",
"GreatLighthouse",
"Colosseum",
"GreatWall"
],
"action_cards_left": [
14,
10,
11,
3,
2,
37,
5,
20,
34,
4,
25,
21,
39,
22,
32,
8,
1,
26,
16,
23,
42,
6,
12,
33,
13,
36,
31,
15,
17,
9,
7,
30,
41,
28,
29,
38,
19,
27,
40,
35
],
"objective_cards_left": [
2,
9,
31,
19,
15,
27,
11,
29,
28,
18,
38,
13,
20,
10,
16,
1,
12,
21,
6,
36,
3,
33,
35,
30,
14,
37,
8,
22,
25,
32,
17,
23,
5,
26,
24,
34
],
"incidents_left": [
24,
48,
33,
1,
16,
15,
14,
58,
12,
2,
11,
13,
19,
25,
7,
55,
20,
45,
10,
8,
52,
42,
51,
40,
37,
35,
32,
47,
43,
46,
41,
36,
57,
49,
26,
17,
6,
18,
28,
4,
38,
44,
53,
5,
34,
21,
3,
50,
30,
9,
23,
56,
29,
39,
31,
27,
22,
54
]
}

View file

@ -0,0 +1,816 @@
{
"version": 2,
"seed": "clash-tutorial-v1",
"state": "Playing",
"players": [
{
"id": 0,
"resources": {
"food": 2,
"wood": 2,
"ore": 3,
"ideas": 3,
"gold": 3,
"mood_tokens": 7,
"culture_tokens": 7
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D2",
"mood_state": "Happy",
"city_pieces": {
"wonders": [
"GreatLighthouse"
]
}
}
],
"units": [
{
"position": "D2",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Rome",
"available_leaders": [
"Caesar",
"Augustus",
"Sulla"
],
"advances": [
"Farming",
"Mining",
"Fishing",
"Myths"
],
"incident_tokens": 3,
"action_cards": [
18
],
"objective_cards": [
4
],
"next_unit_id": 1,
"name": "You"
},
{
"id": 1,
"resources": {
"food": 2
},
"resource_limit": {
"food": 2,
"wood": 7,
"ore": 7,
"ideas": 7,
"gold": 7
},
"cities": [
{
"position": "D7",
"mood_state": "Happy"
}
],
"units": [
{
"position": "D7",
"unit_type": "Settler",
"id": 0
}
],
"civilization": "Persia",
"available_leaders": [
"Cyrus",
"Darius",
"Xerxes"
],
"advances": [
"Farming",
"Mining"
],
"incident_tokens": 3,
"action_cards": [
24
],
"objective_cards": [
7
],
"next_unit_id": 1,
"name": "Opponent"
},
{
"id": 2,
"civilization": "Barbarians",
"next_unit_id": 0
},
{
"id": 3,
"civilization": "Pirates",
"next_unit_id": 0
}
],
"map": {
"tiles": [
[
"A3",
"Unexplored"
],
[
"A5",
"Unexplored"
],
[
"A7",
"Unexplored"
],
[
"B2",
"Unexplored"
],
[
"B3",
"Unexplored"
],
[
"B4",
"Unexplored"
],
[
"B5",
"Unexplored"
],
[
"B6",
"Unexplored"
],
[
"B7",
"Unexplored"
],
[
"C2",
"Forest"
],
[
"C3",
"Unexplored"
],
[
"C4",
"Unexplored"
],
[
"C5",
"Unexplored"
],
[
"C6",
"Unexplored"
],
[
"C7",
"Unexplored"
],
[
"C8",
"Mountain"
],
[
"D1",
"Water"
],
[
"D2",
"Fertile"
],
[
"D3",
"Unexplored"
],
[
"D4",
"Unexplored"
],
[
"D5",
"Unexplored"
],
[
"D6",
"Unexplored"
],
[
"D7",
"Fertile"
],
[
"D8",
"Barren"
],
[
"E2",
"Mountain"
],
[
"E3",
"Unexplored"
],
[
"E4",
"Unexplored"
],
[
"E5",
"Unexplored"
],
[
"E6",
"Unexplored"
],
[
"E7",
"Unexplored"
],
[
"E8",
"Forest"
],
[
"F2",
"Unexplored"
],
[
"F3",
"Unexplored"
],
[
"F4",
"Unexplored"
],
[
"F5",
"Unexplored"
],
[
"F6",
"Unexplored"
],
[
"F7",
"Unexplored"
],
[
"G3",
"Unexplored"
],
[
"G5",
"Unexplored"
],
[
"G7",
"Unexplored"
]
],
"unexplored_blocks": [
{
"position": {
"top_tile": "B2",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Fertile",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "B4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Forest",
"Water",
"Fertile"
]
}
},
{
"position": {
"top_tile": "B6",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Barren",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D3",
"rotation": 0
},
"block": {
"terrain": [
"Forest",
"Mountain",
"Fertile",
"Mountain"
]
}
},
{
"position": {
"top_tile": "D5",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Mountain",
"Forest",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F2",
"rotation": 0
},
"block": {
"terrain": [
"Fertile",
"Water",
"Fertile",
"Barren"
]
}
},
{
"position": {
"top_tile": "F4",
"rotation": 0
},
"block": {
"terrain": [
"Water",
"Water",
"Mountain",
"Fertile"
]
}
},
{
"position": {
"top_tile": "F6",
"rotation": 0
},
"block": {
"terrain": [
"Mountain",
"Water",
"Fertile",
"Mountain"
]
}
}
]
},
"starting_player_index": 0,
"current_player_index": 0,
"log": [
{
"age": 0,
"rounds": [
{
"round": 0,
"turns": [
{
"turn_type": {
"Setup": {
"player": 0,
"civilization": "Japan"
}
},
"actions": [
{
"action": "StartTurn",
"player": 0,
"items": [
{
"player": 0,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ActionCard": 18
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"HandCard": {
"card": {
"ObjectiveCard": 4
},
"from": "DrawPile",
"to": {
"Hand": 0
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D2",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"MoodChange": {
"city": "D2",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 0,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D2"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
},
{
"turn_type": {
"Setup": {
"player": 1,
"civilization": "Persia"
}
},
"actions": [
{
"action": "StartTurn",
"player": 1,
"items": [
{
"player": 1,
"Resources": {
"resources": {
"food": 2
},
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Farming",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Advance": {
"advance": "Mining",
"incident_token": "NoChange",
"balance": "Gain"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ActionCard": 24
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"HandCard": {
"card": {
"ObjectiveCard": 7
},
"from": "DrawPile",
"to": {
"Hand": 1
}
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Structure": {
"structure": "CityCenter",
"balance": "Gain",
"position": "D7",
"port_position": null
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"MoodChange": {
"city": "D7",
"mood": "Happy"
},
"origin": {
"Ability": "Setup"
}
},
{
"player": 1,
"Units": {
"units": {
"settlers": 1
},
"balance": "Gain",
"position": "D7"
},
"origin": {
"Ability": "Setup"
}
}
]
}
]
}
]
}
]
},
{
"age": 1,
"rounds": [
{
"round": 1,
"turns": [
{
"turn_type": {
"Player": 0
}
}
]
}
]
}
],
"log_index": 0,
"undo_limit": 0,
"actions_left": 3,
"round": 1,
"age": 1,
"messages": [
"Age 1 has started"
],
"rng": "296445263143693867296281034113932097109",
"wonders_left": [
"Pyramids",
"GreatMausoleum",
"GreatLibrary",
"GreatStatue",
"GreatGardens",
"GreatLighthouse",
"Colosseum",
"GreatWall"
],
"action_cards_left": [
14,
10,
11,
3,
2,
37,
5,
20,
34,
4,
25,
21,
39,
22,
32,
8,
1,
26,
16,
23,
42,
6,
12,
33,
13,
36,
31,
15,
17,
9,
7,
30,
41,
28,
29,
38,
19,
27,
40,
35
],
"objective_cards_left": [
2,
9,
31,
19,
15,
27,
11,
29,
28,
18,
38,
13,
20,
10,
16,
1,
12,
21,
6,
36,
3,
33,
35,
30,
14,
37,
8,
22,
25,
32,
17,
23,
5,
26,
24,
34
],
"incidents_left": [
24,
48,
33,
1,
16,
15,
14,
58,
12,
2,
11,
13,
19,
25,
7,
55,
20,
45,
10,
8,
52,
42,
51,
40,
37,
35,
32,
47,
43,
46,
41,
36,
57,
49,
26,
17,
6,
18,
28,
4,
38,
44,
53,
5,
34,
21,
3,
50,
30,
9,
23,
56,
29,
39,
31,
27,
22,
54
]
}

View file

@ -0,0 +1,121 @@
.clash-tutorial {
display: grid;
grid-template-columns: 300px minmax(0, 1fr);
height: 100dvh;
background: #f7f9fa;
color: #263c48;
font-family: 'DM Sans', var(--clash-locale-font, sans-serif), sans-serif;
}
.tutorial-sidebar {
padding: 22px 18px;
overflow: auto;
border-right: 1px solid #d2dee3;
line-height: 1.55;
}
.tutorial-sidebar h2 {
font-size: 22px;
line-height: 1.25;
margin: 10px 0;
}
.bgs-tutorial-heading {
display: flex;
flex-direction: column;
gap: 5px;
}
.bgs-tutorial-heading small {
color: #566c77;
}
.bgs-tutorial-body p {
margin: 14px 0;
}
.bgs-tutorial-target,
.bgs-tutorial-hint {
font-size: 13px;
color: #566c77;
}
.bgs-tutorial-feedback {
padding: 10px;
border-radius: 6px;
background: #e8f3ed;
}
.bgs-tutorial-error {
color: #9c382b;
}
.tutorial-sidebar button {
border: 1px solid #b8cfd0;
border-radius: 7px;
padding: 9px 12px;
background: #fff;
font: inherit;
cursor: pointer;
text-align: start;
}
.tutorial-sidebar button:disabled {
opacity: 0.5;
cursor: default;
}
.bgs-tutorial-controls {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin: 16px 0;
}
.tutorial-choices {
display: flex;
flex-direction: column;
gap: 8px;
margin-top: 20px;
}
.tutorial-choices button {
background: #276b70;
color: white;
border-color: #276b70;
}
.tutorial-board {
min-width: 0;
overflow: auto;
}
@media (max-width: 900px) {
.clash-tutorial {
display: flex;
flex-direction: column;
height: auto;
}
.tutorial-sidebar {
max-height: 42dvh;
border-right: 0;
border-bottom: 1px solid #d2dee3;
padding: 12px 16px;
}
.tutorial-choices {
margin-top: 10px;
}
.tutorial-board {
overflow: visible;
}
}
.bgs-tutorial-playback,
.bgs-tutorial-help {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 7px;
}
.bgs-tutorial-heading strong {
font-size: 21px;
line-height: 1.3;
}
.bgs-tutorial-heading > button {
align-self: flex-start;
padding: 3px 9px;
font-size: 12px;
}
.bgs-tutorial-transport {
display: inline-flex;
align-items: center;
justify-content: center;
}
.bgs-tutorial-highlight {
outline: 3px solid #b58a45;
outline-offset: 3px;
}

View file

@ -1,92 +1,106 @@
import { mount, unmount, tick } from 'svelte';
import { mountLocalization } from './localization';
import { registerViewer } from '@boardgamers/protocol/viewer';
import App from './App.svelte';
import { mountTutorial } from './tutorial/mount';
import { Controller } from './controller';
import css from './style.css?inline';
const source = document.currentScript?.getAttribute('src');
const assetBase = new URL(source ? '.' : '/', source ? new URL(source, location.href) : location.href);
export const viewer = registerViewer<string, string>('clash3d', ({ target, ...commands }) => {
const style = document.createElement('style');
style.textContent = css;
document.head.append(style);
const controller = new Controller(
{
...commands,
clearReplayInfo() {
// BGS clears its replay toolbar with null. Protocol 0.9 types only the open
// range, so use the host's existing close message until it exposes this API.
if (window.parent !== window) window.parent.postMessage({ type: 'replay:info', data: null }, '*');
export const viewer = registerViewer<string, string>(
'clash3d',
({ target, ...commands }) => {
const style = document.createElement('style');
style.textContent = css;
document.head.append(style);
const localization = mountLocalization(target.ownerDocument.body);
const controller = new Controller(
{
...commands,
clearReplayInfo() {
// BGS clears its replay toolbar with null. Protocol 0.9 types only the open
// range, so use the host's existing close message until it exposes this API.
if (window.parent !== window) window.parent.postMessage({ type: 'replay:info', data: null }, '*');
},
},
},
assetBase,
);
const app = mount(App, { target, props: { controller } });
const unlockAudio = (event: Event) => {
if (event.isTrusted) controller.audio.unlock();
};
const clickAudio = (event: Event) => {
if (
event.isTrusted &&
event.target instanceof Element &&
event.target.closest('button:not(:disabled)') &&
!event.target.closest('.city-map-label')
)
controller.audio.play('select');
};
const hoverAudio = (event: Event) => {
if (!(event instanceof PointerEvent)) return;
if (!event.isTrusted || event.pointerType === 'touch' || !(event.target instanceof Element)) return;
const button = event.target.closest('button:not(:disabled):not(.city-map-label)');
if (!button || (event.relatedTarget instanceof Node && button.contains(event.relatedTarget))) return;
controller.audio.play('hover');
};
target.addEventListener('pointerdown', unlockAudio, true);
target.addEventListener('keydown', unlockAudio, true);
target.addEventListener('click', clickAudio, true);
target.addEventListener('pointerover', hoverAudio, true);
const motion = matchMedia('(prefers-reduced-motion: reduce)');
controller.patch({ reducedMotion: motion.matches });
return {
chat: controller.chat,
async onState(state) {
await controller.load(state);
await tick();
},
onReplayStart() {
controller.startPlayback();
},
onReplayTo(index) {
controller.seekPlayback(index);
},
onReplayEnd() {
controller.endPlayback();
},
onPlayer({ index }) {
controller.setPlayer(index);
},
onAvatars(avatars) {
controller.patch({ avatars });
},
onSettings(settings) {
controller.setSettings(settings);
},
onPreferences(prefs) {
controller.setPreferences(prefs);
},
onTheme({ dark }) {
controller.patch({ dark });
},
onError(error) {
controller.handleError(error);
},
destroy() {
target.removeEventListener('pointerdown', unlockAudio, true);
target.removeEventListener('keydown', unlockAudio, true);
target.removeEventListener('click', clickAudio, true);
target.removeEventListener('pointerover', hoverAudio, true);
controller.destroy();
void unmount(app);
style.remove();
},
};
});
assetBase,
);
const stopNames = controller.session.subscribe((session) => {
localization.setNames(session.view?.players.map((player) => player.name) ?? []);
});
const app = mount(App, { target, props: { controller } });
const unlockAudio = (event: Event) => {
if (event.isTrusted) controller.audio.unlock();
};
const clickAudio = (event: Event) => {
if (
event.isTrusted &&
event.target instanceof Element &&
event.target.closest('button:not(:disabled)') &&
!event.target.closest('.city-map-label')
)
controller.audio.play('select');
};
const hoverAudio = (event: Event) => {
if (!(event instanceof PointerEvent)) return;
if (!event.isTrusted || event.pointerType === 'touch' || !(event.target instanceof Element)) return;
const button = event.target.closest('button:not(:disabled):not(.city-map-label)');
if (!button || (event.relatedTarget instanceof Node && button.contains(event.relatedTarget))) return;
controller.audio.play('hover');
};
target.addEventListener('pointerdown', unlockAudio, true);
target.addEventListener('keydown', unlockAudio, true);
target.addEventListener('click', clickAudio, true);
target.addEventListener('pointerover', hoverAudio, true);
const motion = matchMedia('(prefers-reduced-motion: reduce)');
controller.patch({ reducedMotion: motion.matches });
return {
chat: controller.chat,
async onState(state) {
await localization.ready;
await controller.load(state);
await tick();
},
onReplayStart() {
controller.startPlayback();
},
onReplayTo(index) {
controller.seekPlayback(index);
},
onReplayEnd() {
controller.endPlayback();
},
onPlayer({ index }) {
controller.setPlayer(index);
},
onAvatars(avatars) {
controller.patch({ avatars });
},
onSettings(settings) {
controller.setSettings(settings);
},
async onPreferences(prefs) {
controller.setPreferences(prefs);
await localization.setLocale(prefs.locale);
},
onTheme({ dark }) {
controller.patch({ dark });
},
onError(error) {
controller.handleError(error);
},
destroy() {
target.removeEventListener('pointerdown', unlockAudio, true);
target.removeEventListener('keydown', unlockAudio, true);
target.removeEventListener('click', clickAudio, true);
target.removeEventListener('pointerover', hoverAudio, true);
stopNames();
localization.destroy();
controller.destroy();
void unmount(app);
style.remove();
},
};
},
{ tutorial: mountTutorial },
);

View file

@ -0,0 +1,44 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Clash of Cultures tutorials</title>
</head>
<body style="margin: 0">
<div id="app"></div>
<script type="module">
import { chapters } from '/src/tutorial/lessons.ts';
const params = new URLSearchParams(location.search);
let viewer;
if (params.has('built')) {
await new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = '/bundle/viewer.js';
script.onload = resolve;
script.onerror = reject;
document.head.append(script);
});
viewer = window.clash3d;
} else {
viewer = (await import('/src/viewer.ts')).viewer;
}
const chapter = params.get('chapter') ?? chapters[0].id;
const index = chapters.findIndex((c) => c.id === chapter);
await viewer.launchTutorial('#app', {
chapter,
locale: params.get('locale') ?? 'en',
nextChapter:
index < chapters.length - 1
? {
title: chapters[index + 1].title,
open: () => {
params.set('chapter', chapters[index + 1].id);
location.search = params.toString();
},
}
: undefined,
});
</script>
</body>
</html>

View file

@ -1,10 +1,27 @@
import { defineConfig } from 'vite';
import { readFileSync } from 'node:fs';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import { previewApi } from './scripts/preview-api';
export default defineConfig({
base: './',
publicDir: false,
plugins: [
{
name: 'localization-font-licenses',
generateBundle() {
const licenses = Object.fromEntries(
['LICENSE-Noto.txt', 'LICENSE-Noto-Arabic.txt'].map((name) => [
name,
readFileSync(new URL(`./src/localization/fonts/${name}`, import.meta.url), 'utf8'),
]),
);
this.emitFile({
type: 'asset',
fileName: 'font-licenses.json',
source: JSON.stringify(licenses, null, 2),
});
},
},
{
name: 'external-wasm-fallback',
enforce: 'pre',