Reference · Rules, generation and deductions
gameFromProgressfunction
A saved game is rebuilt under the rules. Malformed or unavailable boards return null.
Import it
import { gameFromProgress } from "@johnmorrisdotca/jirai";
Definition
function gameFromProgress(progress: string): Game | null
Parameters
| Name | Type | Description |
|---|---|---|
progress | string | The versioned native move record to validate and replay. |
Returns
Game | null
The validated replayed native game, or null for invalid, unsupported or unavailable saved data.
Examples
import type { Settings } from "@johnmorrisdotca/jirai";
import { gameFromProgress, gameProgress, newGame, play } from "@johnmorrisdotca/jirai";
const settings: Settings={width:3,height:3,mines:1,grid:"square",noGuess:false,opening:"clear",seed:42};
const game=play(newGame(settings),{kind:"reveal",cell:0});
console.log(gameFromProgress(gameProgress(game))?.status);wonWhat it prints (run when this page was built)