TsunagiMounttype
The mounted native board handle and its game, display, action and cleanup methods.
Import it
import type { TsunagiMount } from "@johnmorrisdotca/tsunagi/play";
Definition
type TsunagiMount = {
readonly host: HTMLElement;
game: () => TsunagiGame;
progress: () => TsunagiProgress;
load: (level: {
size: number;
givens: string;
answer?: string;
level?: number;
set?: TsunagiSet;
lines?: Lines;
}) => void;
set: (changes: TsunagiLook & {
explosions?: TsunagiExplosionChoice;
cheats?: boolean;
language?: TsunagiLanguage;
}) => void;
undo: () => void;
restart: () => void;
check: () => void;
cheat: () => void;
fit: () => void;
destroy: () => void;
};
Members
| Name | Type | Description |
|---|---|---|
host | HTMLElement | |
game | () => TsunagiGame | The game as it stands. |
progress | () => TsunagiProgress | |
load | (level: { size: number; givens: string; answer?: string; level?: number; set?: TsunagiSet; lines?: Lines; }) => void | Play another level (or the same one again, fresh). |
set | (changes: TsunagiLook & { explosions?: TsunagiExplosionChoice; cheats?: boolean; language?: TsunagiLanguage; }) => void | Change how the board looks, or how it is played: marks, fill, colours, board, coordinates, explosions, cheats, language. A look takes effect at once; explosions and cheats from the next |
undo | () => void | |
restart | () => void | |
check | () => void | |
cheat | () => void | |
fit | () => void | Zoom and move back to the whole board. |
destroy | () => void | Take the board down: its listeners, its timers and everything it put in the host. |
Examples
import { TSUNAGI_4 } from "@johnmorrisdotca/tsunagi/levels-4";
import type { TsunagiMount } from "@johnmorrisdotca/tsunagi/play";
import { mountTsunagi } from "@johnmorrisdotca/tsunagi/play";
const givens = TSUNAGI_4[0][0];
const answer = TSUNAGI_4[0][1];
const host = document.createElement("div");
document.body.append(host);
const board: TsunagiMount | null = mountTsunagi(host,{size:4,givens,answer,controls:true});
console.log(board?.progress().pairs);
board?.destroy();