Skip to content

The games framework

Games are a framework, not a feature of the chat. The same rules run in four places: a 1:1 conversation, a Retro Zone room, a ranked solo game, and offline against the computer.

crates/games/<name> Rust: rules and computer player
│ built to WebAssembly
@retro/games-wasm every game's rules, loaded once
│
@retro/game-<name> TypeScript wrapper and generated types
│
@retro/games-core the GameDefinition contract and the match engine
│
@retro/games-ui GamePanel and the board (React)
  • A game is a pure GameDefinition: it sets up a state, applies a move, says whose turn it is, when it’s over, and what each seat may see. Randomness comes only from a seeded Rng, so a match can be replayed from its seed.
  • The rules are Rust, so the server and the browser run the exact same code. Rust has no I/O, no clock, and may not panic on anything a client sends.
  • The match engine (createMatch, startSoloMatch, …) is pure TypeScript: it moves a MatchRecord forward, enforces turns and clocks, and records the outcome.
  • The board is a React GameUi in @retro/games-ui, shown inside GamePanel.
Where Engine runs in MatchClient
A conversation The server’s GameService RemoteMatchClient
A Retro Zone room or table A second GameService (rooms) RemoteMatchClient
A ranked solo game on the Zone A third GameService (zone) RemoteMatchClient
Against the computer, offline The browser createLocalMatch

The server’s GameService is game-agnostic. It keeps matches in Redis, sends each player only their own view, and finds rules by kind in apps/server/src/games/registry.ts. The browser finds rules, opponent and board by kind in apps/web/src/games/catalog.ts.

Whiteboard, Decision Wheel and Photo Swap are activities: they run beside a 1:1 conversation like a game, but the server only relays their data. It never reads or stores it. A conversation holds one unfinished game or activity at a time (the conversation claim).

zone.retro.com is a Retro Web site built on the framework: daily and weekly leaderboards for solo games, rooms by skill level with Elo ratings, badges, tournaments and ladders. Scores and ratings are kept in Postgres; badges are awarded only by the server.

Add a game has the steps.