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;
};
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
id | string | Unique within one history. |
spec | RollSpec | |
faces | number[] | Every die's face, in the order thrown: rerolled dice and the dice an explosion added are among them. |
kept | boolean[] | Which faces count: all of them unless some are dropped or rerolled. |
total | number | The kept faces added up, plus the bonus. |
at | number | Epoch milliseconds. |
seed | string | 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; |
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出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。