本文へ移動

Meikyuu迷宮

シード付きの迷路と矢印パズルを作り、番号付きの問題を進め、平面や立体表面で遊べます。

「迷宮」は迷路のように入り組んだ場所を表す言葉です。 名前について(英語)

目次

リファレンス · 遊べる盤

MeikyuuMount型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

The mounted flat maze, arrow or mixed board, its game/actions, view and cleanup handle.

インポート

import type { MeikyuuMount } from "@johnmorrisdotca/meikyuu/play";

定義

type MeikyuuMount = {
    readonly host: HTMLElement;
    kind: () => MeikyuuKind;
    puzzle: () => MeikyuuPuzzle;
    mazeGame: () => MazeGame | null;
    arrowGame: () => ArrowGame | null;
    load: (puzzle: {
        kind?: MeikyuuKind;
        level?: number;
        recipe?: MeikyuuMountOptions["recipe"];
        ratio?: MeikyuuMountOptions["ratio"];
    }) => boolean;
    set: (changes: MazeLook & {
        tap?: boolean;
        sound?: boolean;
        hints?: boolean;
        banner?: boolean;
        language?: MeikyuuLanguage;
        ratio?: MeikyuuMountOptions["ratio"];
        stones?: StoneOption;
    }) => void;
    undo: () => void;
    restart: () => void;
    hint: () => void;
    fit: (mode?: FitMode) => void;
    zoomIn: () => void;
    zoomOut: () => void;
    gutter: (px?: number) => number;
    pan: (on?: boolean) => boolean;
    edgePan: (on?: boolean) => boolean;
    orientation: (setting?: MeikyuuOrientation) => {
        setting: MeikyuuOrientation;
        orientation: "portrait" | "landscape";
        turned: boolean;
    };
    stoneMode: (on?: boolean) => boolean;
    stones: () => readonly number[];
    stonesLeft: () => number | null;
    stone: (cell: number) => StoneVerdict;
    clearStones: () => void;
    run: () => string;
    restore: (code: string) => boolean;
    show: (board: "arrows" | "maze") => void;
    destroy: () => void;
};

メンバー

名前型説明
hostHTMLElement
kind() => MeikyuuKind
puzzle() => MeikyuuPuzzle
mazeGame() => MazeGame | null

The maze game as it stands (a maze, or the labyrinth of a mixed puzzle), or null for arrows.

arrowGame() => ArrowGame | null

The arrow game as it stands, or null for a maze.

load(puzzle: { kind?: MeikyuuKind; level?: number; recipe?: MeikyuuMountOptions["recipe"]; ratio?: MeikyuuMountOptions["ratio"]; }) => boolean

Play another puzzle: a level or a recipe. Returns false when there is no such puzzle.

set(changes: MazeLook & { tap?: boolean; sound?: boolean; hints?: boolean; banner?: boolean; language?: MeikyuuLanguage; ratio?: MeikyuuMountOptions["ratio"]; stones?: StoneOption; }) => void

Change how it looks or is played: board, trail, tap, sound, hints, language, the shape of the box (ratio), and the stones' rules (stones; stones already down stay down).

undo() => void
restart() => void
hint() => void
fit(mode?: FitMode) => void

Zoom and move back to the whole board (as fit says, if given), and the gutters back to their least.

zoomIn() => void

Zoom in a step; if the gutters were widened, bring them in a step first.

zoomOut() => void

Zoom out a step; if the whole maze is already in the box, widen the gutters a step instead (to MEIKYUU_GUTTER_MAX).

gutter(px?: number) => number

The gutter now, in pixels, and set it (between the least and MEIKYUU_GUTTER_MAX).

pan(on?: boolean) => boolean

Whether every one-finger drag moves the view; with an argument, turn that on or off.

edgePan(on?: boolean) => boolean

Whether a line drawn to the edge moves the view along; with an argument, turn that on or off.

orientation(setting?: MeikyuuOrientation) => { setting: MeikyuuOrientation; orientation: "portrait" | "landscape"; turned: boolean; }

How the maze is shown: the setting, and what it came to (portrait or landscape as shown, and whether the maze is turned from how it was made). With an argument, change the setting.

stoneMode(on?: boolean) => boolean

Whether the Stone mode is on (a tap lays a stone or takes one up, and nothing draws); with an argument, turn it on or off. Always off for a board with no stones.

stones() => readonly number[]

The cells with a stone on them, in the order they were laid.

stonesLeft() => number | null

How many stones can still be laid: null for no limit, 0 for a board with no stones.

stone(cell: number) => StoneVerdict

Lay a stone on a cell, or take the one there up: the verdict ok when it was done, and otherwise why not (canLayStone).

clearStones() => void

Take every stone up. One Undo puts them back.

run() => string

The run so far as one short text, the line's steps and its stones (encodeRun): what to keep to carry on later.

restore(code: string) => boolean

Carry on a run kept by run(): draws the line and the stones as they were, with one Undo that takes it all back. False, and nothing changed, for a text that is not a run of this maze (or for arrows).

show(board: "arrows" | "maze") => void

For a mixed puzzle: look at the arrows or the labyrinth.

destroy() => void

Take the board down: its listeners, its timers and everything it put in the host.

例

import type { MazeRecipe } from "@johnmorrisdotca/meikyuu";
import type { MeikyuuMount } from "@johnmorrisdotca/meikyuu/play";
import { mountMeikyuu } from "@johnmorrisdotca/meikyuu/play";

const recipe: MazeRecipe = {shape:"square",w:5,h:5,algorithm:"backtracker",mode:"to-goal",seed:42};
const host = document.createElement("div");
document.body.append(host);
const player: MeikyuuMount | null = mountMeikyuu(host,{kind:"maze",recipe});
console.log(player?.kind());
player?.destroy();

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

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