import type { GameState, Handicap, HeadStart, MoveInput } from "./types.ts"; /** The stored shape of a game, as both the API and the pages see it. * * @example * ```ts * import type { StoredGame } from "@johnmorrisdotca/narabe"; * * const stored = {size:15,winLength:5,variant:"freestyle",obstacles:"none",opener:"black",moveTimeMs:null,moves:[{row:7,col:7}]}; * const value: StoredGame = stored; * console.log(value); * ``` */ export type StoredGame = { size: number; winLength: number; variant: string; obstacles: string; opener: string; opening?: string; handicap?: Handicap | null; /** The head start, parsed — see `parseHeadStart`. Games stored before head starts had none. */ headStart?: HeadStart | null; seed?: number; /** See DrawLimit. Games recorded before it existed carry "none", as they were played. */ drawLimit?: string; /** * The clock, or null for none. Required rather than optional: a turn lost to * the clock replays only on a record that had one, and a reader that forgot * to pass it would cut every such game short at the turn that was lost. */ moveTimeMs: number | null; moves: MoveInput[]; }; /** * Rebuilds every position a game passed through by replaying its moves. * * A stored game is a move list, never a board, so this is the only way to read * one back — and because it runs the same engine, a replayed game and a live * one can never disagree about what is legal or who has won. * * Swap-opening decisions are not stored, so a game with one replays as though * the chooser kept their colour: the stones are the same either way. * * @param game - The saved settings and move record to rebuild. * @returns Rebuilds every position a game passed through by replaying its moves. A stored game is a move list, never a board, so this is the only way to read one back — and because it runs the same engine, a replayed game and a live one can never disagree about what is legal or who has won. Swap-opening decisions are not stored, so a game with one replays as though the chooser kept their colour: the stones are the same either way. * @example * ```ts * import { replayTimeline } from "@johnmorrisdotca/narabe"; * * const stored = {size:15,winLength:5,variant:"freestyle",obstacles:"none",opener:"black",moveTimeMs:null,moves:[{row:7,col:7}]}; * console.log(replayTimeline(stored).length); * ``` */ export declare function replayTimeline(game: StoredGame): GameState[]; /** The position as it stands now. * * @param game - The saved settings and move record to rebuild. * @returns The resulting position; a refused or inapplicable action leaves the input position unchanged. * @example * ```ts * import { replayGame } from "@johnmorrisdotca/narabe"; * * const stored = {size:15,winLength:5,variant:"freestyle",obstacles:"none",opener:"black",moveTimeMs:null,moves:[{row:7,col:7}]}; * console.log(replayGame(stored).moves.length); * ``` */ export declare function replayGame(game: StoredGame): GameState;