RollResults
RollResults
A collection of die roll results
TIP
You will probably not need to create your own RollResults instances, unless you're importing rolls, but RollResults objects will be returned when rolling dice.
Kind: global class
- RollResults
- new RollResults([rolls])
- .length ⇒
number - .rolls ⇒
Array.<RollResult> - .rolls
- .value ⇒
number - .addRoll(value)
- .toJSON() ⇒
Object - .toString() ⇒
string
new RollResults([rolls])
Create a RollResults instance.
Throws:
TypeErrorRolls must be an array
| Param | Type | Default | Description |
|---|---|---|---|
| [rolls] | Array.<(RollResult|number)> | [] | The roll results |
Example (`RollResult` objects)
const results = new RollResults([
new RollResult(4),
new RollResult(3),
new RollResult(5),
]);
Example (Numerical results)
const results = new RollResults([4, 3, 5]);
Example (A mix)
const results = new RollResults([
new RollResult(4),
3,
new RollResult(5),
]);
rollResults.length ⇒ number
The number of roll results.
Kind: instance property of RollResults
rollResults.rolls ⇒ Array.<RollResult>
List of roll results.
Kind: instance property of RollResults
rollResults.rolls
Set the rolls.
Kind: instance property of RollResults
Throws:
TypeErrorRolls must be an array
| Param | Type |
|---|---|
| rolls | Array.<RollResult> | Array.<number> |
rollResults.value ⇒ number
The total value of all the rolls after modifiers have been applied.
Kind: instance property of RollResults
rollResults.addRoll(value)
Add a single roll to the list.
Kind: instance method of RollResults
| Param | Type |
|---|---|
| value | RollResult | number |
rollResults.toJSON() ⇒ Object
Return an object for JSON serialising.
This is called automatically when JSON encoding the object.
Kind: instance method of RollResults
rollResults.toString() ⇒ string
Return the String representation of the object.
This is called automatically when casting the object to a string.
Kind: instance method of RollResults