Skip to content

ResultGroup ​

ResultGroup ​

A collection of results and expressions. Usually used to represent the results of a RollGroup instance.

This can contain ResultGroup, RollResults, operators, and plain numbers.

TIP

You will probably not need to create your own ResultGroup instances, unless you're importing rolls, but ResultGroup objects will be returned when rolling group rolls.

Kind: global class
Since: 4.5.0

new ResultGroup([results], [modifiers], [isRollGroup], [useInTotal]) ​

Create a ResultGroup instance.

Throws:

  • TypeError Rolls must be an array
ParamTypeDefaultDescription
[results]Array.<(ResultGroup|RollResults|number|string)>[]The results and expressions
[modifiers]Array.<string> | Set.<string>[]List of modifier names that affect the group
[isRollGroup]booleanfalseWhether the result group represents a roll group or not
[useInTotal]booleantrueWhether to include the group's value when calculating totals

Example (Normal roll: `4d6+2d10`)

js
const results = new ResultGroup([
 new RollResults([3, 5, 4, 2]),
 '+',
 new RollResults([4, 8]),
]);

Example (Roll group: `{4d6+2d10/2, 5d6/2d%}`)

js
const results = new ResultGroup([
 new ResultGroup([
   new RollResults([3, 5, 4, 2]),
   '+',
   new RollResults([4, 8]),
   '/',
   2,
 ]),
 new ResultGroup([
   new RollResults([3, 3, 5, 2, 4]),
   '/',
   new RollResults([87, 46]),
 ]),
]);

resultGroup.calculationValue ⇒ number ​

The value to use in calculations. This may be changed by modifiers.

Kind: instance property of ResultGroup

resultGroup.calculationValue ​

Set the value to use in calculations.

Kind: instance property of ResultGroup
Throws:

  • TypeError value is invalid
ParamType
valuenumber

resultGroup.isRollGroup ⇒ boolean ​

Whether the result group represents a roll group or not.

Kind: instance property of ResultGroup
Returns: boolean - true if it is a roll group, false otherwise

resultGroup.isRollGroup ​

Set whether the result group represents a roll group or not.

Kind: instance property of ResultGroup

ParamType
valueboolean

resultGroup.length ⇒ number ​

The number of results.

Kind: instance property of ResultGroup

resultGroup.modifierFlags ⇒ string ​

The visual flags for the modifiers that affect the group.

Kind: instance property of ResultGroup
See: modifiers

resultGroup.modifiers ⇒ Set.<string> ​

The modifier names that affect the group.

Kind: instance property of ResultGroup

resultGroup.modifiers ​

Set the modifier names that affect the group.

Kind: instance property of ResultGroup
Throws:

  • TypeError modifiers must be a Set or array of modifier names
ParamType
valueArray.<string> | Set.<string>

Example

js
resultGroup.modifiers = ['drop', 'target-success'];

resultGroup.results ⇒ Array.<(ResultGroup|RollResults|number|string)> ​

List of results.

Kind: instance property of ResultGroup

resultGroup.results ​

Set the results.

Kind: instance property of ResultGroup
Throws:

  • TypeError Results must be an array
ParamType
resultsArray.<(ResultGroup|RollResults|number|string)>

resultGroup.useInTotal ⇒ boolean ​

Whether to use the value in total calculations or not.

Kind: instance property of ResultGroup

resultGroup.useInTotal ​

Set whether to use the value in total calculations or not.

Kind: instance property of ResultGroup

ParamType
valueboolean

resultGroup.value ⇒ number ​

The total value of all the results after modifiers have been applied.

Kind: instance property of ResultGroup

resultGroup.addResult(value) ​

Add a single result to the list.

Kind: instance method of ResultGroup
Throws:

  • TypeError Value type is invalid
ParamType
valueResultGroup | RollResults | number | string

resultGroup.toJSON() ⇒ Object ​

Return an object for JSON serialising.

This is called automatically when JSON encoding the object.

Kind: instance method of ResultGroup

resultGroup.toString() ⇒ string ​

Return the String representation of the object.

This is called automatically when casting the object to a string.

Kind: instance method of ResultGroup

MIT Licensed