StandardDice
StandardDice
Represents a standard numerical die.
Kind: global class
- StandardDice
- new StandardDice(sides, [qty], [modifiers], [min], [max], [description])
- .average ⇒
number - .modifiers ⇒
Map.<string, Modifier>|null - .modifiers
- .max ⇒
number - .min ⇒
number - .name ⇒
string - .notation ⇒
string - .qty ⇒
number - .sides ⇒
number - .roll() ⇒
RollResults - .rollOnce() ⇒
RollResult - .toJSON() ⇒
Object - .toString() ⇒
string
new StandardDice(sides, [qty], [modifiers], [min], [max], [description])
Create a StandardDice instance.
Throws:
RequiredArgumentErrorsides is requiredTypeErrorqty must be a positive integer, and modifiers must be valid
| Param | Type | Default | Description |
|---|---|---|---|
| sides | number | The number of sides the die has (.e.g 6) | |
| [qty] | number | 1 | The number of dice to roll (e.g. 4) |
| [modifiers] | Map.<string, Modifier> | Array.<Modifier> | Object | null | | The modifiers that affect the die |
| [min] | number | null | 1 | The minimum possible roll value |
| [max] | number | null | | The maximum possible roll value. Defaults to number of sides |
| [description] | Description | string | null | | The roll description. |
standardDice.average ⇒ number
The average value that the die can roll (Excluding modifiers).
Kind: instance property of StandardDice
standardDice.modifiers ⇒ Map.<string, Modifier> | null
The modifiers that affect this die roll.
Kind: instance property of StandardDice
standardDice.modifiers
Set the modifiers that affect this roll.
Kind: instance property of StandardDice
Throws:
TypeErrorModifiers should be a Map, array of Modifiers, or an Object
| Param | Type |
|---|---|
| value | Map.<string, Modifier> | Array.<Modifier> | Object | null |
standardDice.max ⇒ number
The maximum value that can be rolled on the die, excluding modifiers.
Kind: instance property of StandardDice
standardDice.min ⇒ number
The minimum value that can be rolled on the die, excluding modifiers.
Kind: instance property of StandardDice
standardDice.name ⇒ string
The name of the die.
Kind: instance property of StandardDice
Returns: string - 'standard'
standardDice.notation ⇒ string
The dice notation. e.g. 4d6!.
Kind: instance property of StandardDice
standardDice.qty ⇒ number
The number of dice that should be rolled.
Kind: instance property of StandardDice
standardDice.sides ⇒ number
The number of sides the die has.
Kind: instance property of StandardDice
standardDice.roll() ⇒ RollResults
Roll the dice for the specified quantity and apply any modifiers.
Kind: instance method of StandardDice
Returns: RollResults - The result of the roll
standardDice.rollOnce() ⇒ RollResult
Roll a single die and return the value.
Kind: instance method of StandardDice
Returns: RollResult - The value rolled
standardDice.toJSON() ⇒ Object
Return an object for JSON serialising.
This is called automatically when JSON encoding the object.
Kind: instance method of StandardDice
standardDice.toString() ⇒ string
Return the String representation of the object.
This is called automatically when casting the object to a string.
Kind: instance method of StandardDice
See: notation