本文へ移動

Korokoroコロコロ

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

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

目次

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

Roll型

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

One throw of the dice: what was asked for, every die thrown, and the total.

インポート

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

定義

type Roll = {
    id: string;
    spec: RollSpec;
    faces: number[];
    kept: boolean[];
    total: number;
    at: number;
    seed: string | null;
    dice?: DieRoll[];
    held?: boolean[];
    loaded?: true;
    set?: {
        id: string;
        index: number;
        of: number;
    };
};

メンバー

名前型説明
idstring

Unique within one history.

specRollSpec
facesnumber[]

Every die's face, in the order thrown: rerolled dice and the dice an explosion added are among them.

keptboolean[]

Which faces count: all of them unless some are dropped or rerolled.

totalnumber

The kept faces added up, plus the bonus.

atnumber

Epoch milliseconds.

seedstring | null

The seed this roll came from, when it is reproducible.

dice (省略可)DieRoll[] | undefined

What happened to each die, one entry per face. Every roll this package makes has it; diceOf reads it or works it out.

held (省略可)boolean[] | undefined

On a roll that held some dice from the roll before: which faces were held and not thrown again. Left out of an ordinary roll.

loaded (省略可)true | undefined

True on a roll of loaded dice, and left out of every other: a loaded roll always says so.

set (省略可){ id: string; index: number; of: number; } | undefined

On a roll thrown as one of a set: which set, which roll of it from 0, and how many there are. Left out of a roll thrown on its own.

例

import type { Roll } from "@johnmorrisdotca/korokoro";
import { DEFAULT_SPEC, rollFrom } from "@johnmorrisdotca/korokoro";
const value: Roll = rollFrom(DEFAULT_SPEC, [2, 5], "saved", 0, null)!;
console.log(value.total);
7

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

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

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