@@ -85,6 +85,17 @@ export type RoundItem = {
|
||||
to?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Monotonic revision counter for a game, bumped by the server on every
|
||||
* mutation (queue add/remove, turn commit) and persisted with the state.
|
||||
* Clients use it to tell a fresh state from a stale one: an SSE `state`/`turn`
|
||||
* snapshot (e.g. the on-connect resync) that arrives *after* a fresher REST
|
||||
* response carries a lower version and must be ignored, never applied
|
||||
* (see the client's "never go backwards" rule in src/App.tsx). Legacy games
|
||||
* saved before this field existed are treated as version 0 by consumers.
|
||||
*/
|
||||
export type GameVersion = number;
|
||||
|
||||
/** The full, persisted state of one game. Saved to SQLite by id. */
|
||||
export interface GameState {
|
||||
id: string;
|
||||
@@ -101,6 +112,12 @@ export interface GameState {
|
||||
* batch in a single turn and clears this back to `[]`.
|
||||
*/
|
||||
pending: RoundItem[];
|
||||
/**
|
||||
* Monotonic revision counter (see GameVersion). Bumped on every mutation so
|
||||
* clients can reject stale SSE snapshots; see the "never go backwards" rule
|
||||
* in src/App.tsx. Starts at 1 on game creation.
|
||||
*/
|
||||
version: GameVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user