container/viewer
coyotte508 f806bdef1f Offer "Undo my move" in games against bots
BGS lets the only human of a game against bots take back their last saved
move (protocol 0.10.0). The board toolbar's undo slot shows an "Undo my
move" control while BGS reports it available and the current turn has no
unsaved moves (those keep the in-turn undo); it stays hidden for spectators,
in analysis, during replays and in lessons. Clicking it asks BGS to undo,
which then sends the earlier state: going back in history discards the
local selection, bid drafts and confirmations.

The dev app mimics BGS's undo against its AI players. Also fixes the import
order that failed the prettier check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 11:32:52 +02:00
..
.vscode Add continuous integration 2021-07-04 00:06:50 +02:00
public Add continuous integration 2021-07-04 00:06:50 +02:00
scripts Offer "Undo my move" in games against bots 2026-10-08 11:32:52 +02:00
src Offer "Undo my move" in games against bots 2026-10-08 11:32:52 +02:00
tests Offer "Undo my move" in games against bots 2026-10-08 11:32:52 +02:00
.browserslistrc Move viewer into own folder 2021-07-03 21:27:24 +02:00
.eslintrc.js Add continuous integration 2021-07-04 00:06:50 +02:00
.gitignore ✨ (viewer) Enable loading game directly from json file 2021-10-14 22:23:29 +02:00
babel.config.js Support translated chat and platform analysis defaults 2026-09-21 20:32:09 +02:00
package.json Offer "Undo my move" in games against bots 2026-10-08 11:32:52 +02:00
README.md feat(viewer): support the shared color-blind preference 2026-09-25 17:38:35 +02:00
tsconfig.json Use shared BGS viewer and chat protocol (#10) 2026-09-13 22:54:10 +02:00
vue.config.js Prefill pending bids and retain confirmation when revising auction additions 2026-10-05 16:26:09 +02:00

Container viewer

From the repository root, install with pnpm install.

Local development

pnpm --dir viewer serve

Add ?chapter=supply-chain to open a tutorial. The other chapter IDs are buildings, selling, bidding, keep-cargo and scoring.

Build and check

pnpm --dir viewer check
pnpm --dir viewer test:tutorial
NODE_OPTIONS=--openssl-legacy-provider pnpm --dir viewer package
pnpm --dir viewer test:browser
pnpm --dir viewer test:tutorial:browser

Browser checks use Playwright Chromium. Set CHROMIUM_EXECUTABLE if using an existing installation. pnpm --dir viewer preview:tutorial serves the built viewer on port 5197.

The Vue 2 type checker needs zod available directly in this workspace to resolve the protocol's schema types through pnpm's symlinks. It is a development dependency.

Tutorials on BGS

Upload the same JS and CSS as the ordinary viewer. The container global exposes both launch and launchTutorial. Chapter metadata is exported as chapterCards from src/tutorial/lessons.ts; enter these IDs, versions, titles and descriptions in the BGS version's Tutorial settings.

Lessons run the real engine locally with deterministic opponents and private player views. The extra lesson controls make drag actions accessible on mobile. Chapter progress survives refresh. Playback controls return to the previous step, replay the current step or go back to the start. No live game or chat messages are sent.

Shared accessibility preference

The viewer follows BGS's boolean colorBlind preference (default false). Its eye icon updates the same shared preference through update:preference. Shapes identify container colours across pieces, factories, value cards, trade controls, tutorials and the journal. Player numbers match ships, boards and island rows. No engine state or colour identifiers are changed.

Register { "name": "colorBlind", "label": "Color-blind mode", "type": "checkbox", "default": false } in the BGS viewer preferences.