本文へ移動

Korokoroコロコロ

ダイスを組み合わせて振り、ダイス表記を読み取り、正確な確率を調べます。履歴の保存やシードを指定した再現もできます。

「コロコロ」は、小さなものが転がる様子を表す言葉です。 名前について(英語)

目次

リファレンス · ロールと正確な確率

DieOptions型

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

What a lone die is told when it is made. Everything may be left out.

インポート

import type { DieOptions } from "@johnmorrisdotca/korokoro";

定義

type DieOptions = {
    sides?: Sides;
    faces?: CustomFace[];
    face?: number;
    rollable?: boolean;
    size?: DieSize;
    width?: number;
    onePip?: "red" | "black";
    cloth?: Cloth;
    theme?: Record<`--kk-${string}`, string>;
    locale?: string;
    strings?: Partial<RollerStrings>;
    source?: RandomSource;
    animationMs?: number;
    sound?: boolean;
    playSound?: PlaySound;
    onRoll?: (face: number) => void;
};

メンバー

名前型説明
sides (省略可)Sides | undefined

The kind of die: 2 to 1000 sides, or "F" for a Fate die. 6 when left out.

faces (省略可)CustomFace[] | undefined

A die of your own: its faces, in order, in place of numbers. sides is then their count.

face (省略可)number | undefined

The face showing at first, from 1 (from −1 for a Fate die). Left out, the highest face of the die, or a 6 on a d6.

rollable (省略可)boolean | undefined

Whether a tap rolls it: true when left out. False is a die that only shows a face.

size (省略可)DieSize | undefined

small, medium (unless said) or large. width wins.

width (省略可)number | undefined

Its width in pixels, in place of size.

onePip (省略可)"red" | "black" | undefined

The colour of a d6's one pip: "red" (unless said) or "black".

cloth (省略可)"green" | "blue" | "red" | "black" | "wood" | undefined

A cloth's name, for the page's own colours to follow the tray's: only the ink and the die's edge on a felt. theme is laid over it.

theme (省略可)Record<`--kk-${string}`, string> | undefined

CSS variables for the die, such as { "--kk-die": "#fff" }.

locale (省略可)string | undefined

"ja…" for Japanese, anything else English. The page's own language when left out.

strings (省略可)Partial<RollerStrings> | undefined

Words to use instead of the built-in ones.

source (省略可)RandomSource | undefined

Where the throw comes from: seededSource("table") makes the same throws for everyone. Cryptographic when left out.

animationMs (省略可)number | undefined

The length of the tumble in milliseconds: 600 when left out. Reduced motion always skips it.

sound (省略可)boolean | undefined

Whether a throw makes the sound of dice. Off when left out, because a die on its own is a thing on somebody's page, and a page that has not asked for noise gets none.

playSound (省略可)PlaySound | undefined

A sound of your own for each throw, in place of the recorded dice. Used only when sound is true.

onRoll (省略可)((face: number) => void) | undefined

Called once the die has landed, with the face.

例

import type { DieOptions } from "@johnmorrisdotca/korokoro";
const value: DieOptions = { sides: 20, face: 6, sound: false };
console.log(value.sides);
20

出力(このページを作ったときに実行した結果)

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

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