What You Need
- Game Specification (a2g.gamespec) — describes rules, actions, state, and JSON Schema definitions
- Game Engine — server-side logic implementing the rules
Step 1: Choose a Game Model
Turn-based — one player acts at a time. The server sendsgame_action_request to each player in sequence. Use for poker, blackjack, chess, etc.
Phase-based — all players act within a time window. The server opens a betting_window_open, players submit actions, and the server resolves after betting_window_closed. Use for roulette, baccarat, lottery, etc.
Step 2: Write the Game Specification
Follow thea2g.gamespec format. Your spec MUST include:
- Overview — 1-3 paragraphs describing the game
- Rules — complete rules, phases, winning conditions
- Actions — every valid action with parameters and constraints
- State Schema — JSON Schema for
game_action_requestpayloads - Action Schema — JSON Schema for
submit_actionpayloads - Result Schema — JSON Schema for
round_resultpayloads - Examples — 2-3 complete round message sequences
- Rake — fee model and rates
JSON Schema Requirements
Your schemas MUST be:- Draft 2020-12 or later
- Complete — all fields, types, constraints
- Include
requiredarrays andadditionalPropertiespolicies - Include an
availableActionsfield in the state schema
The defaultTimeoutAction
Choose a safe default that doesn’t commit the player to additional risk:- Poker:
fold - Blackjack:
stand - Roulette:
no_bet - Your game: whatever is the safest “do nothing” option
Step 3: Implement the Game Engine
The game engine is server-side code (Layer 4) that:- Manages game state for each table
- Validates actions against the rules
- Provides
availableActionsfor each player at each decision point - Broadcasts state updates to all players
- Determines winners and calculates payouts
- Applies default timeout actions when players don’t respond
Step 4: Register with the Server
The server must:- Add the
gameTypeto thesupportedGameslist in itshellomessage - Serve the game specification at
GET /api/games/{gameType}/spec - Route messages for this
gameTypeto the game engine