Skip to the content

Sugoroku双六

Play backgammon and its relatives with native rules, cube and match scoring, seeded dice and replayable records.

Sugoroku is the Japanese name 双六 for games of tables. About the name

Contents

Reference · SVG boards and notation

SugorokuDrawOptionstype

What to draw with.

Import it

import type { SugorokuDrawOptions } from "@johnmorrisdotca/sugoroku/draw";

Definition

type SugorokuDrawOptions = {
    variant?: VariantKey | VariantSpec;
    view?: Side;
    home?: "left" | "right";
    orientation?: Orientation;
    numbers?: boolean;
    board?: SugorokuBoardName;
    checkers?: SugorokuCheckerSetName;
    colours?: Partial<SugorokuColours>;
    theme?: "auto" | "light" | "dark";
    dice?: {
        side: Side;
        values: readonly number[];
        spent?: readonly boolean[];
    } | null;
    cube?: {
        value: number;
        owner: Side | null;
    } | null;
    highlight?: {
        side: Side;
        from?: number | null;
        targets?: readonly number[];
        movable?: readonly number[];
    } | null;
    label?: string;
    style?: boolean;
};

Members

NameTypeDescription
variant (optional)VariantKey | VariantSpec | undefined

The variant, for how its sides' points line up. Default backgammon.

view (optional)Side | undefined

Whose home board is at the bottom of the drawing. Default white.

home (optional)"left" | "right" | undefined

Which end of the board the trays are at. Default right.

orientation (optional)Orientation | undefined

Lying across the page (default) or standing up, a better shape for a phone.

numbers (optional)boolean | undefined

Put the numbers of the points beside them, counted for the side view names. Default off.

board (optional)SugorokuBoardName | undefined

A named board, whose surfaces are used; colours is laid over it. Left out, the theme's own.

checkers (optional)SugorokuCheckerSetName | undefined

A named pair of checkers. Left out, the theme's own.

colours (optional)Partial<SugorokuColours> | undefined

Any colours to use instead, each a CSS colour.

theme (optional)"auto" | "light" | "dark" | undefined

light or dark to force the theme; auto (the default) follows the device.

dice (optional){ side: Side; values: readonly number[]; spent?: readonly boolean[]; } | null | undefined

The dice rolled: white's are shown on its half of the board, black's on the other.

cube (optional){ value: number; owner: Side | null; } | null | undefined

The doubling cube, or null (the default) for a game without one, which then has no rail for it.

highlight (optional){ side: Side; from?: number | null; targets?: readonly number[]; movable?: readonly number[]; } | null | undefined

The checker picked up and where it may go, in side's own numbering: from a point or the bar (25), the points (or 0 for off) it may land on, and the points (or the bar) a checker could be picked up from.

label (optional)string | undefined

A description for screen readers.

style (optional)boolean | undefined

Put SUGOROKU_STYLE inside the drawing, so it stands alone as an image. A page with the style in already leaves this off.

Examples

import type { SugorokuDrawOptions } from "@johnmorrisdotca/sugoroku/draw";

const value: SugorokuDrawOptions = {variant:"backgammon",view:"white",numbers:true};
console.log(value);
{ variant: 'backgammon', view: 'white', numbers: true }

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/sugoroku 1.1.1.