本文へ移動

Sugoroku双六

標準の規則、キューブ、試合の得点、シード付きのサイコロ、再生できる記録で、バックギャモンと仲間のゲームを遊べます。

「双六」は、盤と駒で遊ぶゲームの名前です。 名前について(英語)

目次

リファレンス · 遊べる盤面

SugorokuMount型

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

The mounted native board, current game/match/record, actions and cleanup handle.

インポート

import type { SugorokuMount } from "@johnmorrisdotca/sugoroku/play";

定義

type SugorokuMount = {
    readonly host: HTMLElement;
    game: () => GameState;
    match: () => Match;
    record: () => string;
    roll: (dice?: readonly number[]) => void;
    move: (from: number, to: number) => boolean;
    undo: () => void;
    done: () => void;
    double: () => void;
    take: () => void;
    drop: () => void;
    beaver: () => void;
    resign: () => void;
    nextGame: () => void;
    newMatch: (change?: {
        variant?: VariantKey;
        rules?: Partial<Rules>;
        preset?: string;
        seed?: RecordSeed;
    }) => void;
    set: (changes: SugorokuLook & {
        computer?: SugorokuMountOptions["computer"];
        language?: SugorokuLanguage;
        names?: SugorokuMountOptions["names"];
        sound?: boolean | SoundUrls;
    }) => void;
    destroy: () => void;
};

メンバー

名前型説明
hostHTMLElement
game() => GameState

The game as it stands.

match() => Match
record() => string

The match so far as a record a server can replay (see replayRecord).

roll(dice?: readonly number[]) => void

Roll for the side that is to: with no dice, from the seed or at random; with them, the dice the page gives (two for the opening throw, one for white and one for black).

move(from: number, to: number) => boolean

Make a move for the side on turn, from its own point to its own point (the bar is 25, off is 0). False if it is not legal.

undo() => void
done() => void

End the turn once it is played out.

double() => void
take() => void
drop() => void
beaver() => void
resign() => void

Give up the game, as the side on turn.

nextGame() => void

The next game of the match.

newMatch(change?: { variant?: VariantKey; rules?: Partial<Rules>; preset?: string; seed?: RecordSeed; }) => void

A new match, in the same variant and rules unless others are given.

set(changes: SugorokuLook & { computer?: SugorokuMountOptions["computer"]; language?: SugorokuLanguage; names?: SugorokuMountOptions["names"]; sound?: boolean | SoundUrls; }) => void

Change how it looks or who plays: the look, the computer, the language, the names.

destroy() => void

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

例

import { newGame, rollOpening, settingsFor } from "@johnmorrisdotca/sugoroku";
import type { SugorokuMount } from "@johnmorrisdotca/sugoroku/play";
import { mountSugoroku } from "@johnmorrisdotca/sugoroku/play";

const settings = settingsFor("backgammon",{points:5,cube:true});
const game = rollOpening(newGame(settings),[3,1]);
const host = document.createElement("div");
document.body.append(host);
const board: SugorokuMount = mountSugoroku(host,{variant:"backgammon",seed:42,computer:{white:null,black:null}});
console.log(board.game().phase);
board.destroy();

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

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