Chess

Chess asks for a player name and pairs you with the next player waiting, seating the two of you in a shared game. Both of you accept (ready up) before the game begins, and one is given white and the other black by join order. Play is turn-based: on your turn you pick a piece and its destination, the server checks the move is legal for that piece, and then the turn passes. It is a full game on top of Gamehoster: matchmaking, an accept-to-start lobby, an authoritative rules engine, and resignation.

Click / Space to ready up, then click a piece and its destination to move. Open a second window to be the other player.
Live demo against game.gamehoster.org/chess. Open a second window to be the other player. You can also run it locally (docker compose up --build in src/testing) at http://localhost:8080/examples/chess/. If it says “connecting…”, the game server isn’t reachable.

Code

The whole game is a folder of files. Here is Chess's definition, grouped the way this example's tabs are. Each file links to the tab that shows it in full:

chess/
  gamehoster-game.json
  gamehoster-player/
    gamehoster-player-join-schema.json
    gamehoster-player-schema.json
    gamehoster-player-join.js
    gamehoster-player-leave.js
  gamehoster-instance/
    gamehoster-instance-schema.json
    gamehoster-instance-update-backend.js
  gamehoster-commands/
    move/
      gamehoster-command-schema.json
      gamehoster-command.json
      gamehoster-command-handler.js
    ready/
      gamehoster-command-schema.json
      gamehoster-command.json
      gamehoster-command-handler.js
    resign/
      gamehoster-command-schema.json
      gamehoster-command.json
      gamehoster-command-handler.js
  gamehoster-entities/
    piece/
      gamehoster-entity-schema.json
Chess's definition files. The Game, Player, Instance, Commands and Entities tabs show each in full, and the Frontend tab shows the browser code that runs it.