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:
TypeError
Rolls 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),
]);
number
rollResults.length ⇒ The number of roll results.
Kind: instance property of RollResults
Array.<RollResult>
rollResults.rolls ⇒ List of roll results.
Kind: instance property of RollResults
rollResults.rolls
Set the rolls.
Kind: instance property of RollResults
Throws:
TypeError
Rolls must be an array
Param | Type |
---|---|
rolls | Array.<RollResult> | Array.<number> |
number
rollResults.value ⇒ 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 |
Object
rollResults.toJSON() ⇒ Return an object for JSON serialising.
This is called automatically when JSON encoding the object.
Kind: instance method of RollResults
string
rollResults.toString() ⇒ Return the String representation of the object.
This is called automatically when casting the object to a string.
Kind: instance method of RollResults