Docs/Games/Checkers
Games

Checkers

Turn-based, 1v1. The reference implementation for the discrete-move architecture โ€” Tic-tac-toe and Connect 4 follow the same shape.

Turn-based1v1Hosted: socket + REST

Session creation

json
{ "game": "checkers", "matchType": "matchmaking", "players": [{ "id": "user_1" }] }

No game-specific session properties. afkConfig and gameRules aren't registered for this game yet โ€” see each page's own honesty note.

Types

ts
type Player = 'red' | 'black';
type PieceType = 'man' | 'king';
interface Piece { player: Player; type: PieceType; }
type Cell = Piece | null;
type Board = Cell[];   // flat array, index 0-31 (32 playable dark squares)

interface Move {
  from: number;
  to: number;
  captures?: number[];   // indices of captured pieces, if any
}

Connect and join matchmaking

js
const socket = io('https://api.beta-gamer.com/checkers', { auth: { token }, autoConnect: false });
socket.connect();
socket.on('connect', () => {
  socket.emit('matchmaking:join', { playerId, username: 'Alex' });
});

Socket events

EventDirectionPayload
game:startedserver โ†’ client{ roomId, players, board, currentTurn, afkTimeoutEnabled, afkTimeoutSeconds, playerId, color: 'red'|'black' }
game:get_movesclient โ†’ server{ roomId, index: number }
game:valid_movesserver โ†’ client{ index, moves: Move[] }
game:moveclient โ†’ server{ roomId, move: Move, playerId }
game:move:madeserver โ†’ clientBroadcast to the room after a valid move โ€” full updated board + currentTurn
game:overserver โ†’ client{ winner, isDraw, reason }
checkers:afk_warning_clearedserver โ†’ clientFires when a player who was about to be AFK-forfeited moves in time

Making a move

js
socket.emit('game:move', { roomId, playerId, move: { from: 12, to: 16, captures: [8] } });

socket.on('error', ({ message }) => {
  // "Not your turn", "Room not found", "Game is not in progress"
});

Try it

Click a piece, then a highlighted square โ€” watch the exact events on the right, live.

๐Ÿงช MOCKED โ€” no real socket, no server. Real event names and payload shapes, fake data.
Turn: black

Click a piece on turn's color, then a highlighted square. Simplified rules โ€” diagonal steps only, no forced captures โ€” this teaches the wire protocol, not tournament checkers.

Event log
Click a piece to see events fire.

AFK timeout

90 second timeout, 60 second warning โ€” hardcoded for this game, not currently overridable via afkConfig.

Hosted matchmaking

Checkers supports hosted matchmaking via both direct socket events and the REST endpoints documented under Hosted Matchmaking. Either path works identically.

js
socket.emit('hosted:submit_group', { playerIds: ['user_1', 'user_2'] });
socket.on('hosted:group_submitted', ({ groupId }) => { /* ... */ });

socket.emit('hosted:start_match', { groupIds: [groupId] });
socket.on('hosted:match_started', () => { /* game:started follows */ });
matchmaking:join_group also exists as a socket event, alongside the plain matchmaking:joinshown above โ€” for grouping specific players before they enter the general queue. If your integration doesn't need that, the simple join above is all you need.