Reference · Native Minesweeper player
JiraiMounttype
Controls for reading and operating a mounted board.
Import it
import type { JiraiMount } from "@johnmorrisdotca/jirai/play";
Definition
type JiraiMount = {
game: () => Game;
progress: () => string;
play: (cell: number, mark?: boolean) => void;
hint: () => void;
restart: () => void;
load: (settings: Settings, progress?: string) => void;
set: (options: DrawOptions) => void;
destroy: () => void;
};
Members
| Name | Type | Description |
|---|---|---|
game | () => Game | |
progress | () => string | |
play | (cell: number, mark?: boolean) => void | |
hint | () => void | |
restart | () => void | |
load | (settings: Settings, progress?: string) => void | |
set | (options: DrawOptions) => void | |
destroy | () => void |
Examples
import type { Settings } from "@johnmorrisdotca/jirai";
import { newGame, play } from "@johnmorrisdotca/jirai";
import type { JiraiMount } from "@johnmorrisdotca/jirai/play";
import { mountJirai } from "@johnmorrisdotca/jirai/play";
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});
const host=document.createElement("div");
document.body.append(host);
const mounted: JiraiMount=mountJirai(host,{settings});
console.log(mounted.game().status);
mounted.destroy();