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

new RollResults([rolls])

Create a RollResults instance.

Throws:

  • TypeError Rolls must be an array
ParamTypeDefaultDescription
[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:

  • TypeError Rolls must be an array
ParamType
rollsArray.<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

ParamType
valueRollResult | 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