Expand description
Playing a game: moves, resignations, draws, takebacks, aborts, claims, the end of a game (ratings, notifications) and the sweeper that flags clocks and lapses challenges.
Every action locks the game row (FOR UPDATE) in a transaction, works
out the new state with chess-core, writes it and notifies in the same
transaction. Postgres is the only clock (clock_timestamp()), so any
replica can take any request and they all agree on time used.
Enums§
- Api
- Board API (people) or Bot API (bot accounts).
Functions§
- abort
- absent_
secs - Seconds since
playerlast had a stream open on this game (since the game started, if never). - claim_
draw - claim_
in - Seconds until the opponent may claim the win (None:
playerisn’t gone). - claim_
victory - draw
- finish
- End a game: status and winner, ratings for a rated game, fair-play
queueing, and the gameFinish events.
rowmust be locked. - make_
move - resign
- start_
game - Start the game for an accepted challenge (same id as the challenge).
- sweep
- One pass of the sweeper: lapsed challenges, flags and first moves that never came. Safe on every replica at once (rows are locked with SKIP LOCKED and conditions rechecked under the lock).
- takeback
- touch
- Record that
playerhas a stream open on a game.