本文へ移動

Kazu数

検証済みの数独や論理パズルを作り、標準の規則とヒントを読み、盤を描いたり埋め込んだりできます。

「数」は数字を表す言葉です。 名前について(英語)

目次

リファレンス · 遊べる数字の盤

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;
};

メンバー

名前型説明
hostHTMLElement
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). run, notes and elapsed carry on a kept one.

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();

ソースを見るGitHub で編集@johnmorrisdotca/kazu 2.1.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。