Skip to content

@dice-roller/rpg-dice-roller / dice / DieBehaviour

Interface: DieBehaviour ​

Defined in: src/dice/types.ts:46

Optional behaviour a die can provide, instead of the default helpers.

For face dice, bounds default to the extrema, average to the mean including repeats, and face count to the array length. For range dice, average defaults to (min + max) / 2 and face count to max - min + 1. Overrides are resolved with the die as this.

Properties ​

average ​

readonly average: NumberOrGetter

Defined in: src/dice/types.ts:52

Average of a single roll; override this for a custom distribution.


faceCount ​

readonly faceCount: NumberOrGetter

Defined in: src/dice/types.ts:54

Number of faces, including repeats.


max ​

readonly max: NumberOrGetter

Defined in: src/dice/types.ts:50

Highest value, used in max mode; defaults to the highest face for a face die.


min ​

readonly min: NumberOrGetter

Defined in: src/dice/types.ts:48

Lowest value, used in min mode; defaults to the lowest face for a face die.

Methods ​

roll() ​

roll(generator): number

Defined in: src/dice/types.ts:59

Rolls once using the supplied generator; called with the die as this in random mode. It must return a finite number. min / max mode ignores it and uses the resolved bounds.

Parameters ​

generator ​

NumberGenerator

Returns ​

number

MIT Licensed · Credits