本文へ移動

Korokoroコロコロ

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

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

目次

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

Outcome型

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

How a roll is read in a game. A reading is one of a small, fixed set of named functions, so that a new game is a line of data and rarely new code. Each takes the dice, kind by kind, and says what they come to in the game's own terms: an outcome with a stable name, and the figures that go with it. The words for each outcome, in English and Japanese, are in words.ts.

Readings are small and particular on purpose. They do not run a game (turn order, scores across rounds): they read one roll, with the rolls just before it where a game needs them, as craps does for its point.

インポート

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

定義

type Outcome = {
    outcome: string;
    values: Record<string, string | number>;
    tone: "good" | "bad" | "plain";
};

メンバー

名前型説明
outcomestring

The outcome's name within its reading: "natural", "point", "yahtzee".

valuesRecord<string, string | number>

The figures the outcome's words are filled in with.

tone"good" | "bad" | "plain"

Whether it is good news, bad news or neither, for a tray to colour.

例

import type { Outcome } from "@johnmorrisdotca/korokoro";
import { getPreset, presetSpec, roll, seededSource, readDiceAs } from "@johnmorrisdotca/korokoro";
const value: Outcome = readDiceAs(getPreset("cho-han")!.reading, roll(presetSpec(getPreset("cho-han")!), seededSource("docs"), 0));
console.log(value.outcome);
han

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

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

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