powergrid/viewer
goldjohn6 d0f8c48547
SwitzerlandCustom: a new community custom map (#173)
* SwitzerlandCustom: a new custom map (Alpine hydro, neutral Geneva, helicopters)

The seven Swiss Grossregionen, 49 cities, 95 links priced from real distances
(+6 into an Alpine city, +2 over a named pass; Gotthard 16).

- Alpine hydro: each ecological or fusion plant fired powers one more city,
  but only as many of those plants as the player owns Alpine cities
  (City.alpine; alpineBonusLeft / alpineEligible; calculateMaxCitiesPowered).
- Geneva is neutral: all three spaces open from Step 1 (stepSlots [3,3,3]).
- Lake Geneva steamer (sea), Glacier Express, three outskirt helicopters
  (Connection.air, drawn dotted and curved clear of cities). The Glacier
  Express, Oberalp and helicopters never decide which regions are dealt
  together; Ticino gets the Gotthard Base Tunnel and the Lukmanier.
- Viewer: Swiss outline (landlocked: neighbours all round), and the faded
  unplayed regions now cover community custom maps too, without curved links.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* SwitzerlandCustom: green plants only for the Alpine +1; an expensive country

- The Alpine +1 is for green (ecological) plants only, never fusion (John:
  6 + 1 = 7 from one card is too strong). Rules text says so explicitly.
- Starting market: coal opens at $3 and oil at $4, while cheese is plentiful
  and opens at $5; uranium as usual ([18, 15, 12, 2], both editions).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep the Central Europe comment on garbagePrice

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* SwitzerlandCustom: power plants send the engine's offer; Alpine peaks

Found in John's local playtest: the viewer built its own UsePowerPlant move
from the printed card, so the engine refused a green plant with the Alpine
+1. A single-fuel plant now sends the engine's own offer (hybrids keep the
mix the player picked). freePlantMoves takes each offer after the previous
plant fires (on a copy), since the Alpine +1 is shared out; the powered-cities
count includes it. A snow-capped peak sits behind each Alpine city.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* SwitzerlandCustom: cheese opens at $6 (John, after his playtest)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* SwitzerlandCustom: the building-phase power capacity counts the Alpine +1

Found in John's playtest: 18 + 30 + 20 with Alpine cities showed 13, not 14.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* SwitzerlandCustom: the Glacier Express drawn as a red railway

Connection.rail (visual only): red rails over a pale bed, crossed by red ties.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 11:06:59 -08:00
..
.vscode Initial 2021-10-13 00:09:21 -03:00
docs/tutorials Add playable Powergrid tutorials and city income reference (#155) 2026-09-16 10:10:47 -07:00
public Initial 2021-10-13 00:09:21 -03:00
scripts Release phase auto-pass engine 2.0.37 and viewer 2.3.32 2026-11-17 22:21:20 +00:00
src SwitzerlandCustom: a new community custom map (#173) 2026-11-20 11:06:59 -08:00
tests SwitzerlandCustom: a new community custom map (#173) 2026-11-20 11:06:59 -08:00
.browserslistrc Initial 2021-10-13 00:09:21 -03:00
.eslintrc.js 🐛 (engine) auction should follow clockwise order 2021-10-26 00:26:40 -03:00
.gitignore Initial 2021-10-13 00:09:21 -03:00
babel.config.js Reuse auction controls for pending bids and distinguish phase actions 2026-10-05 16:18:56 +02:00
package.json Release phase auto-pass engine 2.0.37 and viewer 2.3.32 2026-11-17 22:21:20 +00:00
pnpm-lock.yaml Offer "Undo my move" in games against bots 2026-10-08 11:41:51 +02:00
README.md Release phase auto-pass engine 2.0.37 and viewer 2.3.32 2026-11-17 22:21:20 +00:00
tsconfig.json Add playable Powergrid tutorials and city income reference (#155) 2026-09-16 10:10:47 -07:00
vue.config.js Reuse auction controls for pending bids and distinguish phase actions 2026-10-05 16:18:56 +02:00

powergrid-viewer

Project setup

yarn install

Compiles and hot-reloads for development

yarn serve

Compiles and minifies for production

yarn build

Run your unit tests

yarn test:unit

Lints and fixes files

yarn lint

Customize configuration

See Configuration Reference.

Playable tutorials

Seven independent chapters cover auctions, fuel, connections, income, plant replacement, Steps 2/3 and final scoring. They use Germany with classic rules, deterministic positions and scripted opponents. Actions go through the real engine; only the learner's filtered state reaches the board.

From the repository root:

pnpm --dir engine build
pnpm --dir viewer test:tutorial
NODE_OPTIONS=--openssl-legacy-provider pnpm --dir viewer package
pnpm --dir viewer test:tutorial:browser
pnpm --dir viewer preview:tutorial

Open http://127.0.0.1:5199/?chapter=auctions. Other chapter IDs are resources, network, income, upgrades, steps and final-round.

The ordinary viewer bundle exposes both powergrid.launch and powergrid.launchTutorial. Upload the entry JS, CSS and all .umd.min.locale-*.js chunks and configure the tutorial chapters on the same BGS game version. pnpm --dir viewer tutorial:manifest prints the chapter metadata. No second bundle or engine release is required.

Lessons live in src/tutorial/lessons.ts. Keep their IDs stable and increase a chapter's version when changing its setup or accepted actions would invalidate saved progress. Test normal board clicks, refresh, rewind and completion on desktop and mobile before release.

See the desktop and mobile screenshots for examples of the tutorial UI.

Undo against bots

When the only human of a game plays against bots, BGS can take back their last saved move (protocol 0.10.0 undo:available / undo). The board's Undo button then becomes "Undo my move" once the turn in progress has nothing left to undo locally. It stays hidden during replays, analyses and round planning, for spectators, and while a move is on its way. BGS answers with the earlier state, and the viewer drops the turn buffer, open dialogs and the bid being dialled. The development sandbox (npm run serve) offers the same undo against its bots.

Shared accessibility preference

The viewer accepts BGS's colorBlind boolean preference (default false). The eye button on the board changes it through update:preference, so BGS saves the setting across games. It also works locally in tutorials.

When enabled, houses on the map, turn-order track and city-count track carry their owner's seat number. Player panels use the same number, regardless of turn order or selected color. City rims use contrasting dash and dot patterns to distinguish map regions without extra labels. Each region keeps its pattern after region selection. Resources already use different shapes.

Local phase auto-pass preview (no BGS connection)

From the repository root, build the engine and viewer, then start the preview:

pnpm --dir engine build
NODE_OPTIONS=--openssl-legacy-provider pnpm --dir viewer exec vue-cli-service build --target lib --name powergrid-viewer src/wrapper.ts
node viewer/scripts/auction-preview.mjs

Open http://127.0.0.1:5216/?mode=fuel-hidden (or ?mode=city-hidden). The scenario selector also offers public-money versions and an empty oil market. Toggle the checkbox in your player card, then click Ada's action in the top bar. Ada takes the last affordable oil/city and finishes via the real engine wrapper. Hidden money without opt-in retains your turn; opt-in or public money skips it. An empty oil market skips even with hidden money and opt-in disabled, because the impossibility is public. Reset before comparing scenarios. Preferences persist through the wrapper's private player-settings API; no client-side auto-pass simulation is used. Preview state is held in memory only.

Run the eight browser scenarios after building:

node viewer/scripts/phase-auto-pass-smoke.mjs
node viewer/scripts/auto-pass-label-smoke.mjs

The label smoke checks all 17 languages at 390px and 1400px, switching phases and locales live and checking left alignment, checkbox clearance and row bounds. To verify a published viewer, set POWERGRID_VIEWER_URL to its public powergrid-viewer.umd.min.js URL when running either smoke. Only viewer assets are fetched from the CDN; game state, moves and settings remain local in memory.