Add seven scenarios and publish the private Fuji playtest

This commit is contained in:
coyotte508 2026-09-08 20:49:43 +02:00
commit 5531387d98
16 changed files with 469 additions and 54 deletions

View file

@ -2,7 +2,9 @@
A playable first implementation of Wolfgang Warsch’s cooperative game for Boardgamers, with artwork by Weberson Santiago supplied by Feuerland.
This is a **local alpha**, not a published or publisher-approved final adaptation. It implements scenario 1, two to four players (two-player variant A), all four difficulty levels, six skills and fifteen equipment effects. The visual direction uses the original illustrations as an interactive landscape, with private dice totals, route previews, revealed comparisons and state-driven lava.
This is a **private playtest alpha**, not a publisher-approved final adaptation. It implements all seven scenarios, two to four players (two-player variant A), all four difficulty levels, six skills and fifteen equipment effects. The visual direction uses the original illustrations as an interactive landscape, with private dice totals, route previews, revealed comparisons and state-driven lava.
Canonical source: [codeberg.org/boardgamers/fuji](https://codeberg.org/boardgamers/fuji).
## Run
@ -13,7 +15,7 @@ pnpm install
pnpm dev
```
Open `http://127.0.0.1:5187`. The local harness keeps a playtest in browser storage. Click an adventurer to switch seats. **Play next teammate action** advances a simple, non-omniscient test player one action; it is a testing aid, not a strategic AI. **New game** replaces the local save.
Open `http://127.0.0.1:5187`. The local harness keeps a playtest in browser storage. Click an adventurer to switch seats. **Play next teammate action** advances a simple, non-omniscient test player one action; it uses the same cooperative equipment and route heuristics as the platform AI. **New game** replaces the local save.
```sh
pnpm check
@ -47,3 +49,7 @@ pnpm test:browser
```
If Chromium is already installed in a non-default location, set `FUJI_CHROMIUM_EXECUTABLE` to its executable path. Screenshots are written under the ignored `work/browser` directory. The second smoke test loads the actual production bundle with a minimal BGS emitter host, checks readiness and state refresh, verifies the move payload, and confirms that Wireless exposes the correct dice without loading the local harness.
Private release: build with `pnpm check`, pack the engine with `pnpm --filter fuji-engine pack --pack-destination ../..`, then run `BGS_TOKEN_FILE=/path/to/token node scripts/publish-private.mjs`. The script registers private version 1, uploads bundles and rules, and grants Spock and AlphaZero access. It refuses to overwrite an existing game without review.
Run `FUJI_ALL_SCENARIOS=1 pnpm simulate` for 1,050 seeded expeditions across all seven maps.

View file

@ -1,6 +1,6 @@
{
"label": "Fuji",
"description": "Escape Mount Fuji together. Private alpha: scenario 1.",
"description": "Escape Mount Fuji together. Private alpha: all seven scenarios.",
"players": [2, 3, 4],
"credits": "Game design: Wolfgang Warsch. Illustrations: Weberson Santiago. Publisher: Feuerland Spiele.",
"public": false,
@ -18,9 +18,46 @@
"dependencies": {
"scripts": [],
"stylesheets": []
}
},
"fullScreen": true
},
"options": [
{
"name": "scenario",
"label": "Scenario",
"type": "select",
"default": "1",
"items": [
{
"name": "1",
"label": "Scenario 1"
},
{
"name": "2",
"label": "Scenario 2"
},
{
"name": "3",
"label": "Scenario 3"
},
{
"name": "4",
"label": "Scenario 4"
},
{
"name": "5",
"label": "Scenario 5"
},
{
"name": "6",
"label": "Scenario 6"
},
{
"name": "7",
"label": "Scenario 7"
}
]
},
{
"name": "difficulty",
"label": "Difficulty",
@ -29,19 +66,19 @@
"items": [
{
"name": "1",
"label": "Level 1"
"label": "Level 1 (tie or lower: lose 3 stamina)"
},
{
"name": "2",
"label": "Level 2"
"label": "Level 2 (tie or lower: lose 4 stamina)"
},
{
"name": "3",
"label": "Level 3"
"label": "Level 3 (tie or lower: lose 5 stamina)"
},
{
"name": "4",
"label": "Level 4"
"label": "Level 4 (tie or lower: lose 6 stamina)"
}
]
}
@ -53,5 +90,9 @@
"type": "checkbox",
"default": false
}
]
],
"alias": null,
"links": {
"source": "https://codeberg.org/boardgamers/fuji"
}
}

View file

@ -2,7 +2,7 @@
## Evidence
The publisher-supplied English production rulebook is `EN_Fuji_Regel_PRINT_3_130918.pdf` (13 September 2018). Terrain faces are transcribed from `fuji_land_front_Print3.pdf`; setup from scenario card 1; skills and equipment from the English fronts and rulebook appendix. The stamina track has exhaustion at step 25, with injury thresholds at steps 5, 10, 15 and 20.
The publisher-supplied English production rulebook is `EN_Fuji_Regel_PRINT_3_130918.pdf` (13 September 2018). Terrain faces are transcribed from `fuji_land_front_Print3.pdf`; setup from all seven scenario cards; skills and equipment from the English fronts and rulebook appendix. The stamina track has exhaustion at step 25, with injury thresholds at steps 5, 10, 15 and 20.
The terrain names used in the UI are descriptive navigation labels, not printed card titles. Terrain IDs are the one-based production PDF page numbers.
@ -21,20 +21,20 @@ Each full set contains two of each type. This remains observation-derived rather
## Implemented first slice
- Scenario 1, including the additional village and split starting positions at four players.
- All seven scenarios, including the additional village and split starting positions at four players.
- All 24 landscape and 6 village card criteria, including AND/OR conditions and reroll symbols; scenario setup shuffles the appropriate decks.
- Two-player variant A: six neutral dice, three visible during planning and three hidden until reveal. No neutral pawn.
- Four difficulty levels; strict comparisons against seated neighbors; ties fail; stamina and immediate team defeat/victory.
- Equipment preparation choices and one-die removal for five-die skills.
- Six skills, fifteen equipment effects, donor consent for the lighter, per-player mandatory Carabiner rerolls, staged Water rerolls and Tinkerer reuse.
- Set-aside dice visible to everyone and excluded from comparisons; temporary loans return after the round; leg-injury removal occurs after all comparisons.
- Phase-five movement order is chosen by the players. Power bars are offered by their owner, rather than automatically spent by the recipient.
- Phase-five movement order is chosen automatically, prioritizing survival and accounting for eruptions. Power bars are offered by their owner, rather than automatically spent by the recipient.
- Additional eruptions are applied when traversing eruption markers; ordinary eruptions propagate one wave, never recursively through the entire map.
- Win triggers as soon as everyone reaches the village, before further stamina deductions or eruptions.
## Deliberate alpha boundaries and interpretations
1. Only scenario 1 is enabled. Scenarios 2–7, the advanced two-player variant B and the extra-thrill double-eruption variant are not yet implemented.
1. The advanced two-player variant B and the extra-thrill double-eruption variant are not yet implemented.
2. For a five-die skill, the player chooses which die to leave behind before any dice are rolled. The supplied material has not established the official selection procedure. This is an explicit provisional rule.
3. The two-player simple variant splits one of each inferred type into the visible and hidden halves. The text specifies three visible and three hidden dice but does not mandate this split.
4. A planned path is explicit. If an earlier extra eruption blocks that path, resolution treats it as a failed move unless an alternative legal path to the same locked destination is supplied. Check this interpretation against the publisher before beta release.
@ -46,7 +46,7 @@ Each full set contains two of each type. This remains observation-derived rather
## Next acceptance checks
Play full expeditions with people familiar with the physical game. Verify the provisional interpretations, five-die selection and every equipment/skill combination against the physical reference. Extend scenario data from the already-supplied seven cards. Validate BGS multiplayer, clocks, reconnection and cooperative outcomes before publication.
Play full expeditions with people familiar with the physical game. Verify the provisional interpretations, five-die selection and every equipment/skill combination against the physical reference. Validate BGS multiplayer, clocks, reconnection and cooperative outcomes before publication.
### Automatic movement order
@ -73,3 +73,9 @@ The wrapper's `currentPlayer` excludes players with confirmed planning intention
Public movement paths and eruption cell lists in journal events allow the viewer to sequence automatic resolution without extra engine moves or saved intermediate states. The map and journal play events in order, with a skip control; the authoritative received state and platform clocks are unchanged. Initial loads and seat changes show the current state immediately. Reduced motion skips intermediate path positions. The local bot driver waits for playback and uses a 2.2-second action cadence. Confirmed-route journal records preserve the original terrain, equipment and eruption markers and reroll allowance. Equipment is public (rulebook page 8, face-up cards) and appears as pictograms with hover previews on player panels.
Sound effects combine a CC0 recording of real dice throws (see `audio-credits.md`) with synthesized Web Audio foley synchronized with presented events (steps, lava, dice, equipment), governed by the platform's reserved `preferences.sound` boolean (absent means enabled, per platform PR #503). No game-specific preference overrides the platform mute. The harness offers a local sound toggle, individual cue previews, and a random-seed restart. Copy equipment, shovel values, preparation dice and local game configuration expose their choices directly without select controls.
## Seven-scenario validation
All seven layouts were transcribed from the supplied production scenario fronts. Layout tests cover every player count, unique terrain cards, five/six village tiles, seven equipment markers, two eruption markers, connected maps and both starting positions. All seven maps were rendered in the harness.
Adaptation rule: a player with no other reachable, unclaimed destination may confirm staying despite a neighbor sharing that destination. This prevents isolated players from stalling planning before lava ends the expedition. Normal destination restrictions still apply when another route is available.

112
docs/rules.md Normal file
View file

@ -0,0 +1,112 @@
# Fuji: how to play
Fuji is a cooperative escape game for 2–4 players. Everyone must reach a village location before the lava or exhaustion catches anyone. The house symbols mark village locations. The counter beside the map shows how many players have arrived.
This private alpha implements all seven scenarios and the simple two-player variant with neutral dice. Choose a scenario to change the map layout, starting positions, equipment tokens and eruption markers. Each seed shuffles terrain cards within that layout. Scenario numbers are not difficulty levels.
Terrain names in the viewer are navigation labels added for this adaptation.
## Your expedition
Each player has private dice, a character skill, equipment and 25 stamina. Some skills start with five dice instead of six. During preparation, make any equipment and die choices the viewer offers. Players with no preparation choice proceed automatically.
The player cards show remaining stamina (♥), injuries, public equipment and the Gatherer's power bars. Hover over an injury or equipment pictogram for its effect. Gold player-card borders indicate players who can act.
## Each round
### 1. Plan together
Your dice are rolled behind your screen. Choose a destination up to three steps away along connected locations, or stay where you are. The Scout can travel four steps. Lava-covered locations cannot be entered.
Clicking a location shares your provisional route. You can revise it until the team finishes planning. Click **Ready to travel** when satisfied. Neighboring players cannot choose the same destination. In a four-player game, your comparison neighbors are the players immediately before and after you in seating order, not the opposite player.
Discuss plans, but do not communicate exact dice values, counts, averages or statements that indirectly reveal those numbers. You may say that a destination looks promising or that your roll is poor. Wireless is an equipment exception that explicitly reveals dice.
The viewer picks a path that avoids eruption markers where possible. A location threatened by the next eruption requires an explicit danger acknowledgement before selection. Equipment marked for planning can be used during this phase.
### 2. Reroll in silence
Once everyone is ready, destinations are locked. Normal rerolls depend on the planned distance:
| Distance | Rerolls |
| ------------- | ------: |
| Stay in place | 2 |
| 1–2 steps | 1 |
| 3 steps | 0 |
A destination marked ↻ grants one extra reroll. Survivalist adds one. An eye injury removes normal and location-bonus rerolls; Survivalist's extra reroll remains. A four-step Scout route grants no rerolls.
**One reroll can reroll any number of your dice together, including all of them.** Select the dice, then press Reroll. You may select different dice on each attempt or finish early. Having fewer dice does not itself reduce your reroll allowance.
Matching dice are marked with their contribution to your own destination. Colored player-number badges identify dice that also count against a teammate's destination. Buddy may set one die aside during this phase. The Gatherer collects unused rerolls as power bars, up to three.
### 3. Use equipment
Discussion resumes. You may use equipment available in this phase, then confirm readiness. Open a card to see its effect and select any required dice, location or recipient. Used equipment is discarded, except that Tinkerer may use a card twice. New equipment found on the trail becomes available next round.
Equipment can also create a decision for another player: a loan request may be accepted or declined, and a granted reroll lets its recipient choose dice. The viewer waits only for meaningful decisions.
### 4. Compare and move
All dice are revealed. For your destination, add the values of every die matching its symbols. For example, yellow-or-six counts yellow dice and all sixes, with each die counted once. Several listed numbers mean every die showing any of those numbers counts.
Compare your total against each comparison neighbor's dice using **your destination's criteria**. You must strictly beat both totals. A tie or lower result means you stay. In the simple two-player variant, the neutral dice provide the additional comparison.
The adaptation chooses movement order automatically, taking eruptions into account. A Gatherer may be asked whether to spend power bars; each bar adds one to the moving player's total. No one needs to confirm a movement that has no remaining choice.
Staying still also requires the dice comparison and can cost stamina. Moving successfully does not automatically mean zero stamina loss.
### 5. Lose stamina and advance lava
Your **lead** is your total minus the highest comparison total. At level 1:
| Lead | Stamina lost |
| ------------ | -----------: |
| Tie or lower | 3 |
| 1–2 | 2 |
| 3–4 | 1 |
| 5 or more | 0 |
At each higher difficulty, add one to the loss before applying the minimum of zero. Thus a level-4 tie loses six stamina, and a lead of eleven is needed to lose none. First aid prevents stamina loss for the round but does not make a failed comparison succeed.
The permanent guide below the map shows the table for the current difficulty. Difficulty changes stamina costs, not the normal movement distance, reroll allowance or lava speed.
Crossing the stamina thresholds at 20, 15, 10 and 5 remaining stamina gives an injury. Choose an injury you do not already have: arm prevents equipment use; eye reduces rerolls; amnesia removes your skill; leg permanently removes a die after the round's comparisons.
Crossing an eruption marker triggers its extra eruption(s). After all journeys are resolved, the ordinary eruption advances lava to every adjacent location. A player caught by lava, or reaching zero stamina, ends the expedition in defeat. These effects resolve automatically and appear in the journal.
## Equipment reference
| Equipment | Effect |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Binoculars | During planning, swap any two completely empty land tiles, at any distance. No players, destination markers, equipment tokens, eruption markers, village tiles or lava. |
| Flare gun | Add three to your own movement value this round. This bonus does not increase the total teammates must beat. |
| Rope | Immediately move to an adjacent land tile during planning or equipment. |
| Shovel | Turn one die to any face. |
| Torch | During planning, reroll any selection of your dice once. |
| Pocketknife | Copy an eligible equipment card held by another player. |
| Water flask | Take up to two rerolls yourself, or grant one to a teammate. |
| First aid kit | Lose no stamina this round. |
| Wireless | Reveal your dice to everyone until the phase ends. |
| Tape | Turn any of your ones into sixes. |
| Compass | Turn any of your sixes into ones. |
| Machete | Set aside one or two dice. They become visible but do not count this round. |
| Fire lighter | Ask a teammate to lend you one die for the round. |
| Carabiner | Every player must reroll exactly one die. |
| Map | Lend one die to a teammate for the round. |
Set-aside and loaned dice return at the end of the round. The Equipment manager can give an equipment card to another player without being on the same location. The card's use phase and availability still apply.
## Winning and expedition points
You win together as soon as everyone stands on a village location. Reaching the village alone does not remove you from the game or protect you from later lava.
On victory, the viewer adds the team's expedition points: four per player, minus one per injury, plus one per remaining equipment card. It is a cooperative team score, not a competition between players.
## About this playtest
This is a private alpha. All seven scenarios, automatic movement ordering and simple two-player neutral dice are the supported configuration. The dice color/value composition was reconstructed from supplied photographs and is still awaiting publisher confirmation. Platform clocks and cooperative rankings are being evaluated during private testing; the in-game team outcome is authoritative.
Game design: Wolfgang Warsch. Illustrations: Weberson Santiago. Publisher: Feuerland Spiele. Source code: [Codeberg](https://codeberg.org/boardgamers/fuji), licensed under AGPL-3.0. Publisher artwork remains separately copyrighted.
If no other unclaimed destination is reachable, you can confirm staying even when a neighbor must stay there too. Play continues normally, including an eruption that may end the expedition.

View file

@ -6,6 +6,7 @@ import {
activePlayers,
neighbors,
paths,
mustStay,
cell,
rerollAllowance,
activeDice,
@ -324,6 +325,7 @@ export function chooseMove(game: View, seat: number, policy: AiPolicy = DEFAULT_
if (equipment) return equipment;
}
if (game.phase === "planning") {
if (mustStay(game, seat)) return p.path.length === 1 ? { action: "ready" } : { action: "plan", path: [p.position] };
const choices = Object.values(paths(game, seat)).filter(
(path) =>
!neighbors(game, seat).some((i) => game.players[i]!.ready && game.players[i]!.path.at(-1) === path.at(-1))

View file

@ -184,3 +184,65 @@ export const SCENARIO_ONE = [
[" ", "E", " ", " ", "L", " ", "L", " "],
[" ", " ", " ", " ", "E", "L", "E", " "],
];
// Production scenario cards 2–7. S/S4: white/grey starts; vX: village eruption.
// Grey starts remain ordinary land at every player count; only V4 is omitted.
export const SCENARIOS = [
SCENARIO_ONE,
[
". . . . L E L .",
". . . . E . L .",
". L L L L X E .",
"E S4 L . . L . V4",
". S . . E L . v",
"R R . . . L . v",
"V . . E L L vX v",
". . . . . E . v",
],
[
"L L E . E L E L",
"S . L . L . . E",
"S4 L L L X L L X",
"R . L E . L . vE",
"R . . . . E . v",
"V . . . . . . v",
". . . . . V4 v v",
],
[
". . . . E . . .",
". . E L L L vX vE",
"V . . . L . . v",
"R . E L L E . v",
"R . . . X . . v",
"S S4 L L L . . V4",
". L E . E . . .",
],
[
". . L E L . V .",
". . E . L . R .",
". . L E L S R .",
"V4 . L . . L S4 .",
"v . E . . L . .",
"v . X L L L L E",
"v . L . . . E .",
"vX v L E . . . .",
],
[
". . . E . . . .",
"R S S4 L . E L E",
"R . L L . L . L",
"V . . L X L L E",
". . . E . E L .",
". . . . . . L E",
". V4 v v v v vX .",
],
[
". . E . . . E .",
". L L . . E L .",
"E L L L X L L E",
". vX . . . L E .",
"v v . . . L . .",
"v . . V . S4 E .",
"v V4 . R R S . .",
],
].map((rows) => rows.map((row) => (typeof row === "string" ? row.split(" ").map((c) => (c === "." ? " " : c)) : row)));

View file

@ -1065,3 +1065,60 @@ test("Rope and copied Rope log one movement entry and retain the animation", ()
assert.deepEqual(entries[0]!.animation, { kind: "move", seat: 0, path: [s.players[0]!.position, "1,3"] });
}
});
test("all seven official layouts preserve terrain decks, markers, starts and connected paths", () => {
const starts = [
["0,3", "1,2"],
["1,4", "1,3"],
["0,1", "0,2"],
["0,5", "1,5"],
["5,2", "6,3"],
["1,1", "2,1"],
["5,6", "5,5"],
];
for (let scenario = 1; scenario <= 7; scenario++)
for (const players of [2, 3, 4]) {
const s = initGame(players, { scenario }, "scenario-layout");
assert.equal(s.scenario, scenario);
assert.equal(s.board.filter((c) => terrain(c.terrain).kind === "village").length, players === 4 ? 6 : 5);
assert.equal(s.board.filter((c) => c.lava).length, 1);
assert.equal(s.board.filter((c) => c.eruption).length, 2);
assert.equal(s.board.filter((c) => c.equipment).length, 7);
assert.equal(new Set(s.board.map((c) => c.terrain)).size, s.board.length);
assert(s.board.every((c) => terrain(c.terrain)));
assert.equal(s.players[0]!.position, starts[scenario - 1]![0]);
if (players === 4) assert.equal(s.players[2]!.position, starts[scenario - 1]![1]);
const seen = new Set([s.board[0]!.id]);
for (let i = 0; i < s.board.length; i++)
for (const c of s.board) {
if (s.board.some((b) => seen.has(b.id) && Math.abs(b.x - c.x) + Math.abs(b.y - c.y) === 1)) seen.add(c.id);
}
assert.equal(seen.size, s.board.length, `Connected scenario ${scenario}`);
assert.deepEqual(replay(s), s);
}
for (const scenario of [0, 8, 1.5, "invalid"]) assert.throws(() => initGame(3, { scenario }));
});
test("trapped neighbors can all confirm staying and still lose to the eruption", () => {
let s = prepared();
const position = s.players[0]!.position;
s.board.forEach((c) => {
c.lava = c.id !== position;
});
s.players.forEach((p) => {
p.position = position;
p.path = [position];
p.ready = false;
});
for (let seat = 0; seat < 3; seat++) s = applyMove(s, { action: "ready" }, seat);
assert.equal(s.phase, "reroll");
s.phase = "eruption";
s = applyMove(s, { action: "erupt" }, 0);
assert.equal(s.outcome, "lost");
});
test("a shared destination remains forbidden when another route is available", () => {
let s = prepared();
s.players[0]!.ready = true;
assert.throws(() => applyMove(s, { action: "ready" }, 1), /different destinations/);
});

View file

@ -5,7 +5,7 @@ import {
EXHAUSTION,
INJURIES,
INJURY_AT,
SCENARIO_ONE,
SCENARIOS,
SKILLS,
CHARACTERS,
terrain,
@ -86,6 +86,20 @@ export function paths(s: State | View, seat: number, max?: number): Record<strin
}
return found;
}
// Staying is always confirmable when no distinct, unclaimed destination exists.
// Do not let a shared start trap the expedition in planning before inevitable lava.
export function mustStay(s: State | View, seat: number): boolean {
const p = s.players[seat]!;
const claimed = new Set(
neighbors(s, seat)
.filter((i) => s.players[i]!.ready)
.map((i) => s.players[i]!.path.at(-1))
);
return !Object.keys(paths(s, seat)).some((id) => id !== p.position && !claimed.has(id));
}
function forcedStay(s: State | View, seat: number, route: string[]): boolean {
return route.length === 1 && route[0] === s.players[seat]!.position && mustStay(s, seat);
}
export function rerollAllowance(s: State | View, seat: number, path?: string[]): number {
const p = s.players[seat]!;
const chosen = path ?? p.path;
@ -221,8 +235,8 @@ export function initGame(players = 3, options: Record<string, unknown> = {}, see
if (!Number.isInteger(players) || players < 2 || players > 4) throw Error("Fuji supports 2–4 players.");
const difficulty = Number(options.difficulty ?? 1);
if (!Number.isInteger(difficulty) || difficulty < 1 || difficulty > 4) throw Error("Choose difficulty 1–4.");
if (options.scenario !== undefined && Number(options.scenario) !== 1)
throw Error("This edition currently implements scenario 1.");
const scenario = Number(options.scenario ?? 1);
if (!Number.isInteger(scenario) || scenario < 1 || scenario > 7) throw Error("Choose scenario 1–7.");
const s: State = {
schemaVersion: 1,
seed,
@ -234,6 +248,7 @@ export function initGame(players = 3, options: Record<string, unknown> = {}, see
deck: [],
discard: [],
difficulty,
scenario,
log: [],
revision: 0,
outcome: null,
@ -251,7 +266,8 @@ export function initGame(players = 3, options: Record<string, unknown> = {}, see
);
const villages = shuffle(s, [28, 29, 30, 31, 32, 33]);
let rubble = 2;
SCENARIO_ONE.forEach((row, y) =>
const layout = SCENARIOS[scenario - 1]!;
layout.forEach((row, y) =>
row.forEach((code, x) => {
if (code === " " || (code === "V4" && players !== 4)) return;
const village = code.startsWith("v") || code === "V4";
@ -263,7 +279,7 @@ export function initGame(players = 3, options: Record<string, unknown> = {}, see
terrain: id,
lava: code === "V",
equipment: code.includes("E"),
eruption: code === "X" ? 1 : 0,
eruption: code.includes("X") ? 1 : 0,
});
})
);
@ -277,7 +293,9 @@ export function initGame(players = 3, options: Record<string, unknown> = {}, see
if (skillList.length < players || skillList.some((x) => !(x in SKILLS))) throw Error("Invalid skill selection.");
for (let i = 0; i < players; i++) {
const skill = skillList[i]!;
const pos = players === 4 && i >= 2 ? "1,2" : "0,3";
const start = players === 4 && i >= 2 ? "S4" : "S";
const startY = layout.findIndex((row) => row.includes(start));
const pos = `${layout[startY]!.indexOf(start)},${startY}`;
const p: Player = {
name: CHARACTERS[i]!,
character: i,
@ -320,7 +338,7 @@ export function initGame(players = 3, options: Record<string, unknown> = {}, see
}));
s.ghostVisible = s.ghost.filter((_, j) => j % 2 === 0).map((d) => d.id);
}
event(s, "Scenario 1 · the path to the village", "phase");
event(s, `Scenario ${scenario} · the path to the village`, "phase");
if (s.players.every((p) => p.setupDone)) startRound(s);
return s;
}
@ -577,7 +595,10 @@ function execute(s: State, m: Move, seat: number) {
case "plan": {
if (s.phase !== "planning") throw Error("Routes are locked for this round.");
const route = validatePath(s, p, m.path, hasSkill(p, "scout") ? 4 : 3);
if (neighbors(s, seat).some((i) => s.players[i]!.path.at(-1) === route.at(-1) && s.players[i]!.ready))
if (
!forcedStay(s, seat, route) &&
neighbors(s, seat).some((i) => s.players[i]!.path.at(-1) === route.at(-1) && s.players[i]!.ready)
)
throw Error("A neighbor has already selected that destination.");
p.path = route;
p.ready = false;
@ -588,7 +609,10 @@ function execute(s: State, m: Move, seat: number) {
if (p.ready) throw Error("Already ready.");
if (s.phase === "planning") {
validatePath(s, p, p.path, hasSkill(p, "scout") ? 4 : 3);
if (neighbors(s, seat).some((i) => s.players[i]!.ready && s.players[i]!.path.at(-1) === p.path.at(-1)))
if (
!forcedStay(s, seat, p.path) &&
neighbors(s, seat).some((i) => s.players[i]!.ready && s.players[i]!.path.at(-1) === p.path.at(-1))
)
throw Error("Neighbors need different destinations.");
}
p.ready = true;

View file

@ -97,6 +97,7 @@ export interface State {
deck: EquipmentId[];
discard: EquipmentId[];
difficulty: number;
scenario?: number;
log: Event[];
revision: number;
outcome: null | "won" | "lost";

View file

@ -4,6 +4,7 @@
terrain,
cell,
paths,
mustStay,
neighbors,
rerollAllowance,
matches,
@ -34,6 +35,7 @@
import PhaseIcon from "./lib/PhaseIcon.svelte";
import RequirementDisplay from "./lib/RequirementDisplay.svelte";
import PlayerChoices from "./lib/PlayerChoices.svelte";
import TravelGuide from "./lib/TravelGuide.svelte";
import StaminaGuide from "./lib/StaminaGuide.svelte";
let { store }: { store: Store } = $props();
const s = $derived(store.state);
@ -70,6 +72,7 @@
let newGame = $state(false);
let newPlayers = $state(3);
let newDifficulty = $state(1);
let newScenario = $state(1);
let newSeed = $state("first-light");
const reachable = $derived(s && seat !== undefined ? paths(s, seat) : {});
const reserved = $derived.by(() => {
@ -79,6 +82,7 @@
const player = s.players[i]!;
if (player.ready) locations[player.path.at(-1)!] = player.name;
}
if (mustStay(s, seat)) delete locations[s.players[seat]!.position];
}
return locations;
});
@ -410,7 +414,7 @@
<button
onclick={() => {
newSeed = crypto.randomUUID().slice(0, 8);
store.restart(s.players.length, newSeed, s.difficulty);
store.restart(s.players.length, newSeed, s.difficulty, s.scenario ?? 1);
}}>New random game</button
>
</div>
@ -1220,6 +1224,17 @@
</div>
{#if newPlayers === 2}<p class="muted small">Includes neutral dice.</p>{/if}
</fieldset>
<fieldset class="visible-choices">
<legend>Scenario</legend>
<div class="choice-row">
{#each [1, 2, 3, 4, 5, 6, 7] as n}<button aria-pressed={newScenario === n} onclick={() => (newScenario = n)}
>{n}</button
>{/each}
</div>
<p class="muted small">
Seven official map layouts. The seed shuffles terrain and equipment within the chosen layout.
</p>
</fieldset>
<fieldset class="visible-choices">
<legend>Difficulty</legend>
<div class="choice-row">
@ -1227,6 +1242,8 @@
>Level {n}</button
>{/each}
</div>
<p class="muted small">Higher levels increase stamina loss. Routes, rerolls and lava speed stay the same.</p>
<TravelGuide difficulty={newDifficulty} />
</fieldset>
<label class="field">Expedition seed<input bind:value={newSeed} /></label><button
class="text-button"
@ -1234,7 +1251,7 @@
><button
class="primary"
onclick={() => {
store.restart(newPlayers, newSeed, newDifficulty);
store.restart(newPlayers, newSeed, newDifficulty, newScenario);
newGame = false;
inspected = "";
}}>Begin expedition <span>→</span></button

View file

@ -65,8 +65,8 @@ store.selectSeat = (seat) => {
store.error = "";
publish();
};
store.restart = (players, seed, difficulty) => {
game = initGame(players, { difficulty }, seed);
store.restart = (players, seed, difficulty, scenario = 1) => {
game = initGame(players, { difficulty, scenario }, seed);
store.seat = 0;
publish();
};

View file

@ -28,6 +28,15 @@
} = $props();
const danger = $derived(threatened(state));
const mapWidth = $derived(116 + Math.max(...state.board.map((c) => c.x)) * 100);
// Use empty map space without adding a footer where the layout allows it.
const guidePosition = $derived(
({ 1: [14, 519], 2: [14, 603], 3: [14, 519] } as Record<number, number[]>)[state.scenario ?? 1]
);
const guideX = $derived(guidePosition?.[0] ?? 14);
const guideY = $derived(guidePosition?.[1] ?? 100 + Math.max(...state.board.map((c) => c.y)) * 84);
const mapHeight = $derived(
Math.max(100 + Math.max(...state.board.map((c) => c.y)) * 84, guideY + (state.difficulty >= 3 ? 111 : 91))
);
const x = (id: string) => 58 + cell(state, id).x * 100;
const y = (id: string) => 54 + cell(state, id).y * 84;
const edges = $derived(
@ -47,7 +56,9 @@
<div class="scene-caption">
<span class="eyebrow">THE FUJI TRAIL</span>
<div class="scene-meta">
<span>Scenario 01 <span class="dot">·</span> Level {state.difficulty}</span><span
<span
>Scenario {String(state.scenario ?? 1).padStart(2, "0")} <span class="dot">·</span> Level {state.difficulty}</span
><span
class="legend-end"
title="Everyone must reach any house-marked village location at the same time."
aria-label={`${state.players.filter((p) => terrain(cell(state, p.position).terrain).kind === "village").length} of ${state.players.length} players in the village`}
@ -68,7 +79,7 @@
</div>
<div class="map-scroll">
<svg
viewBox={`0 0 ${mapWidth} ${state.difficulty >= 3 ? 630 : 610}`}
viewBox={`0 0 ${mapWidth} ${mapHeight}`}
class="map"
aria-label="Expedition map. Choose a location to inspect or plan a journey."
>
@ -248,7 +259,7 @@
{#if i === seat}<path d="M-4 -28H4L0 -22Z" fill="#f4d888" />{/if}
</g>
{/each}
<foreignObject x="14" y="519" width="385" height={state.difficulty >= 3 ? 106 : 86} class="map-guides">
<foreignObject x={guideX} y={guideY} width="385" height={state.difficulty >= 3 ? 106 : 86} class="map-guides">
<div xmlns="http://www.w3.org/1999/xhtml">
<div class="scene-legend">
<span

View file

@ -63,7 +63,7 @@ export class Store {
}
send: (move: Move) => void = () => {};
selectSeat: (seat: number) => void = () => {};
restart: (players: number, seed: string, difficulty: number) => void = () => {};
restart: (players: number, seed: string, difficulty: number, scenario?: number) => void = () => {};
teammateStep: () => void = () => {};
dispatch(move: Move) {
if (this.animating && this.blocksInput) return;

View file

@ -0,0 +1,72 @@
// Private BGS release. Credentials are read from a file, never logged or embedded.
import { readFileSync } from "node:fs";
import assert from "node:assert/strict";
import { homedir } from "node:os";
const base = "https://admin.boardgamers.space/api";
const token = readFileSync(process.env.BGS_TOKEN_FILE || `${homedir()}/.bgs`, "utf8").trim();
async function request(path, method = "GET", body, raw = false) {
const response = await fetch(base + path, {
method,
headers: {
Authorization: `Bearer ${token}`,
...(body ? { "Content-Type": raw ? "application/octet-stream" : "application/json" } : {}),
},
body: body ? (raw ? body : JSON.stringify(body)) : undefined,
});
if (!response.ok) throw Error(`${method} ${path}: ${response.status} ${(await response.text()).slice(0, 800)}`);
return response.json();
}
const version = "/admin/gameinfo/fuji/1";
const draft = JSON.parse(readFileSync("bgs-gameinfo.draft.json", "utf8"));
assert.equal(draft.public, false);
const versions = await request("/admin/gameinfo/fuji/versions");
if (versions.length) {
const existing = await request(version);
if (versions.length !== 1 || existing.public !== false || existing.viewer?.url || existing.engine?.package?.url)
throw Error("Fuji already exists. Review its current version before uploading a replacement.");
}
await request(version, "PUT", {
...draft,
...(versions.length ? { unlisted: true } : {}),
rules: "[How to play Fuji](https://boardgamers.space/page/fuji/rules)",
});
console.log("Registered private Fuji v1.");
await request(version + "/engine", "POST", readFileSync("fuji-engine-0.1.0.tgz"), true);
const js = await request(
version + "/viewer/file?filename=fuji-viewer.iife.js",
"POST",
readFileSync("packages/viewer/dist/fuji-viewer.iife.js"),
true
);
const css = await request(
version + "/viewer/file?filename=fuji-viewer.css",
"POST",
readFileSync("packages/viewer/dist/fuji-viewer.css"),
true
);
const current = await request(version);
await request(version, "PUT", {
...current,
alias: current.alias ?? null,
public: false,
viewer: { ...draft.viewer, url: js.url, dependencies: { scripts: [], stylesheets: [css.url] } },
});
await request("/admin/page/fuji:rules/en", "PUT", {
title: "Fuji: how to play",
content: readFileSync("docs/rules.md", "utf8"),
});
for (const usernameOrEmail of ["Spock", "AlphaZero"]) {
const grant = await request("/admin/gameinfo/fuji/beta-users", "POST", { usernameOrEmail });
console.log(`Granted ${grant.username} access to v${grant.maxVersion}.`);
}
const saved = await request(version);
assert.equal(saved.public, false);
assert(saved.engine.package.url);
assert.equal(saved.viewer.url, js.url);
for (const url of [saved.engine.package.url, js.url, css.url]) {
const response = await fetch(url, { method: "HEAD" });
assert(response.ok, `Hosted asset unavailable: ${response.status}`);
}
const rules = await request("/admin/page/fuji:rules/en");
assert(rules.content.includes("seven scenarios"));
console.log("Private release, hosted assets and rules verified.");

View file

@ -3,26 +3,30 @@ import { currentPlayer } from "../packages/engine/dist/wrapper.js";
import assert from "node:assert/strict";
let moves = 0,
wins = 0;
for (let players = 2; players <= 4; players++)
for (let seed = 0; seed < 50; seed++) {
let s = initGame(players, { difficulty: 1 + (seed % 4) }, `simulation-${seed}`);
let steps = 0;
while (!s.outcome && steps < 1000) {
const current = currentPlayer(s);
const active = current === undefined ? [] : Array.isArray(current) ? current : [current];
assert(active.length, "Active game must offer an action");
const seat = active[0];
s = moveAI(s, seat);
assert.equal(
new Set(s.players.flatMap((p) => p.dice.map((d) => d.id))).size,
s.players.reduce((n, p) => n + p.dice.length, 0)
);
assert(s.players.every((p) => p.stamina >= 0 && p.stamina <= 25));
steps++;
const scenarios = process.env.FUJI_ALL_SCENARIOS ? [1, 2, 3, 4, 5, 6, 7] : [1];
for (const scenario of scenarios)
for (let players = 2; players <= 4; players++)
for (let seed = 0; seed < 50; seed++) {
let s = initGame(players, { difficulty: 1 + (seed % 4), scenario }, `simulation-${seed}`);
let steps = 0;
while (!s.outcome && steps < 1000) {
const current = currentPlayer(s);
const active = current === undefined ? [] : Array.isArray(current) ? current : [current];
assert(active.length, "Active game must offer an action");
const seat = active[0];
s = moveAI(s, seat);
assert.equal(
new Set(s.players.flatMap((p) => p.dice.map((d) => d.id))).size,
s.players.reduce((n, p) => n + p.dice.length, 0)
);
assert(s.players.every((p) => p.stamina >= 0 && p.stamina <= 25));
steps++;
}
assert(s.outcome, `Deadlock: ${scenario}/${players}/${seed}`);
assert.deepEqual(replay(s), s);
moves += steps;
if (s.outcome === "won") wins++;
}
assert(s.outcome, `Deadlock: ${players}/${seed}`);
assert.deepEqual(replay(s), s);
moves += steps;
if (s.outcome === "won") wins++;
}
console.log(`150 complete expeditions; ${moves} moves; ${wins} wins; no deadlocks; exact replays.`);
console.log(
`${150 * scenarios.length} complete expeditions; ${moves} moves; ${wins} wins; no deadlocks; exact replays.`
);

View file

@ -296,7 +296,7 @@ import path from "node:path";
await page.locator(".comparison").waitFor();
if (await page.getByRole("button", { name: "Confirm result" }).count()) throw Error("Resolver should not confirm");
if ((await page.locator(".teammate.can-act").count()) !== 1) throw Error("Only the Gatherer should be active");
if (!(await page.locator(".public-bars").innerText()).includes("2 power bars"))
if (!(await page.locator(".public-bars").getAttribute("aria-label"))?.includes("2 power bars"))
throw Error("Public power bars missing");
if (!(await page.getByText("Can help", { exact: true }).isVisible()))
throw Error("Gatherer help availability missing");