KazuMount型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The native mounted number grid, its current game/detail, controls and cleanup methods.
インポート
import type { KazuMount } from "@johnmorrisdotca/kazu/play";
定義
type KazuMount = {
readonly host: HTMLElement;
game: () => KazuGame;
detail: () => KazuEventDetail;
load: (puzzle: Pick<KazuMountOptions, "kind" | "size" | "givens" | "solution" | "level" | "seed" | "run" | "notes" | "elapsed">) => boolean;
set: (changes: KazuMountSettings) => void;
select: (cell: number | null) => void;
enter: (value: number) => void;
pencil: (on?: boolean) => void;
undo: () => void;
hint: () => void;
check: () => void;
restart: () => void;
destroy: () => void;
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
host | HTMLElement | |
game | () => KazuGame | The game as it stands. |
detail | () => KazuEventDetail | What the events would tell now. |
load | (puzzle: Pick<KazuMountOptions, "kind" | "size" | "givens" | "solution" | "level" | "seed" | "run" | "notes" | "elapsed">) => boolean | Play another puzzle (or the same one again, fresh). |
set | (changes: KazuMountSettings) => void | Change how it plays: hints, check, conflicts, peers, tidy, tapToStep, language, clock, controls. |
select | (cell: number | null) => void | Choose a cell (or none, with null). |
enter | (value: number) => void | Write a number into the chosen cell, or a pencil mark if Pencil is on; 0 empties the cell. |
pencil | (on?: boolean) => void | Turn Pencil on or off. |
undo | () => void | |
hint | () => void | |
check | () => void | |
restart | () => void | Start again: every entry gone and the clock at nothing. |
destroy | () => void | Take the board down: its listeners, its timers and everything it put in the host. |
例
import type { KazuPuzzle } from "@johnmorrisdotca/kazu";
import { decodeCells } from "@johnmorrisdotca/kazu";
import type { KazuMount } from "@johnmorrisdotca/kazu/play";
import { mountKazu } from "@johnmorrisdotca/kazu/play";
const puzzle: KazuPuzzle = {"kind":"number-place","size":4,"level":"easy","seed":42,"givens":"14..2..1412.3..4","solution":"1432234141233214"};
const kind = puzzle.kind;
const size = puzzle.size;
const givens = puzzle.givens;
const answer = puzzle.solution;
const solution = decodeCells(answer,size)!;
const host = document.createElement("div");
document.body.append(host);
const board: KazuMount | null = mountKazu(host,{kind,size,givens,solution:answer});
console.log(board?.detail().progress);
board?.destroy();この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。