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:
RequiredArgumentError
sides is requiredTypeError
qty 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. |
number
standardDice.average ⇒ The average value that the die can roll (Excluding modifiers).
Kind: instance property of StandardDice
Map.<string, Modifier>
| null
standardDice.modifiers ⇒ 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:
TypeError
Modifiers should be a Map, array of Modifiers, or an Object
Param | Type |
---|---|
value | Map.<string, Modifier> | Array.<Modifier> | Object | null |
number
standardDice.max ⇒ The maximum value that can be rolled on the die, excluding modifiers.
Kind: instance property of StandardDice
number
standardDice.min ⇒ The minimum value that can be rolled on the die, excluding modifiers.
Kind: instance property of StandardDice
string
standardDice.name ⇒ The name of the die.
Kind: instance property of StandardDice
Returns: string
- 'standard'
string
standardDice.notation ⇒ The dice notation. e.g. 4d6!
.
Kind: instance property of StandardDice
number
standardDice.qty ⇒ The number of dice that should be rolled.
Kind: instance property of StandardDice
number
standardDice.sides ⇒ The number of sides the die has.
Kind: instance property of StandardDice
RollResults
standardDice.roll() ⇒ Roll the dice for the specified quantity and apply any modifiers.
Kind: instance method of StandardDice
Returns: RollResults
- The result of the roll
RollResult
standardDice.rollOnce() ⇒ Roll a single die and return the value.
Kind: instance method of StandardDice
Returns: RollResult
- The value rolled
Object
standardDice.toJSON() ⇒ Return an object for JSON serialising.
This is called automatically when JSON encoding the object.
Kind: instance method of StandardDice
string
standardDice.toString() ⇒ 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