SuidoMount型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The native mounted board, its game and view, actions and cleanup methods.
インポート
import type { SuidoMount } from "@johnmorrisdotca/suido/play";
定義
type SuidoMount = {
readonly host: HTMLElement;
game: () => Game;
flow: () => Flow;
progress: () => string;
load: (board: {
code: string;
answer?: string;
progress?: string;
shown?: boolean;
}) => void;
set: (changes: {
turning?: SuidoTurning;
hints?: boolean;
language?: SuidoLanguage;
}) => void;
turn: (cell: number, back?: boolean) => void;
restart: () => void;
hint: () => void;
view: () => SuidoView;
zoom: (how: "in" | "out" | "fit") => void;
destroy: () => void;
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
host | HTMLElement | |
game | () => Game | The game as it stands. |
flow | () => Flow | The water as it runs now. |
progress | () => string | The game half played, as a short string to keep. |
load | (board: { code: string; answer?: string; progress?: string; shown?: boolean; }) => void | Play another board (or the same one again, fresh). |
set | (changes: { turning?: SuidoTurning; hints?: boolean; language?: SuidoLanguage; }) => void | Change how it is played: the turning, whether Hint is offered, the language. |
turn | (cell: number, back?: boolean) => void | Turn the piece on a cell, a quarter clockwise or ( |
restart | () => void | Start the board over: every piece as given, no turns, no hints. |
hint | () => void | Light a piece to turn, as the Hint button does. |
view | () => SuidoView | The view of the board: how far in it is, and where. Whole (zoom 1) unless it has been zoomed. |
zoom | (how: "in" | "out" | "fit") => void | Zoom the board in or out a step, or back to the whole of it, as the buttons do. |
destroy | () => void | Take the board down: its listeners, its frames and everything it put in the host. |
例
import { SUIDO_5X5 } from "@johnmorrisdotca/suido/levels-5x5";
import { levelAnswer } from "@johnmorrisdotca/suido/levels";
import type { SuidoMount } from "@johnmorrisdotca/suido/play";
import { mountSuido } from "@johnmorrisdotca/suido/play";
const row = SUIDO_5X5[0];
const code = row[0];
const answer = levelAnswer(row)!;
const host = document.createElement("div");
document.body.append(host);
const board: SuidoMount | null = mountSuido(host,{code,answer,controls:true});
console.log(board?.progress());
board?.destroy();この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。