NarabeGame型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
A React game state and its native move, replay and reset actions.
インポート
import type { NarabeGame } from "@johnmorrisdotca/narabe/react";
定義
type NarabeGame = {
state: GameState;
choices: TurnChoices | null;
play: (point: Point, kind?: MoveKind, colour?: Stone | null) => void;
move: (from: Point, to: Point) => void;
place: (cells: readonly PieceCell[]) => void;
twist: (quadrant: number, clockwise: boolean) => void;
pass: () => void;
undo: () => void;
canUndo: boolean;
reset: (settings?: Partial<GameSettings>) => void;
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
state | GameState | The game as it stands. A new object after every move that changed it. |
choices | TurnChoices | null | What the player to move may do, or null when there is no set of moves to show. See |
play | (point: Point, kind?: MoveKind, colour?: Stone | null) => void | Places a stone at |
move | (from: Point, to: Point) => void | Moves a piece: |
place | (cells: readonly PieceCell[]) => void | Lays a queued piece on these cells: |
twist | (quadrant: number, clockwise: boolean) => void | Turns a quadrant to finish a twist game's move: |
pass | () => void | Passes the turn where the rules allow it: |
undo | () => void | Takes back the last move, where there is one to take back. |
canUndo | boolean | |
reset | (settings?: Partial<GameSettings>) => void | Starts again, with these settings or the ones this game began with. |
例
import { createElement } from "react";
import { useNarabe, type NarabeGame } from "@johnmorrisdotca/narabe/react";
function Board() {
const game: NarabeGame = useNarabe({variant:"reversi"});
return createElement("p",null,game.state.toPlay);
}
console.log(createElement(Board));この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。