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
- ResultGroup
- new ResultGroup([results], [modifiers], [isRollGroup], [useInTotal])
- .calculationValue ⇒
number
- .calculationValue
- .isRollGroup ⇒
boolean
- .isRollGroup
- .length ⇒
number
- .modifierFlags ⇒
string
- .modifiers ⇒
Set.<string>
- .modifiers
- .results ⇒
Array.<(ResultGroup|RollResults|number|string)>
- .results
- .useInTotal ⇒
boolean
- .useInTotal
- .value ⇒
number
- .addResult(value)
- .toJSON() ⇒
Object
- .toString() ⇒
string
new ResultGroup([results], [modifiers], [isRollGroup], [useInTotal])
Create a ResultGroup
instance.
Throws:
TypeError
Rolls must be an array
Param | Type | Default | Description |
---|---|---|---|
[results] | Array.<(ResultGroup|RollResults|number|string)> | [] | The results and expressions |
[modifiers] | Array.<string> | Set.<string> | [] | List of modifier names that affect the group |
[isRollGroup] | boolean | false | Whether the result group represents a roll group or not |
[useInTotal] | boolean | true | Whether to include the group's value when calculating totals |
Example (Normal roll: `4d6+2d10`)
const results = new ResultGroup([
new RollResults([3, 5, 4, 2]),
'+',
new RollResults([4, 8]),
]);
Example (Roll group: `{4d6+2d10/2, 5d6/2d%}`)
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]),
]),
]);
number
resultGroup.calculationValue ⇒ 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
Param | Type |
---|---|
value | number |
boolean
resultGroup.isRollGroup ⇒ 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
Param | Type |
---|---|
value | boolean |
number
resultGroup.length ⇒ The number of results.
Kind: instance property of ResultGroup
string
resultGroup.modifierFlags ⇒ The visual flags for the modifiers that affect the group.
Kind: instance property of ResultGroup
See: modifiers
Set.<string>
resultGroup.modifiers ⇒ 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
Param | Type |
---|---|
value | Array.<string> | Set.<string> |
Example
resultGroup.modifiers = ['drop', 'target-success'];
Array.<(ResultGroup|RollResults|number|string)>
resultGroup.results ⇒ 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
Param | Type |
---|---|
results | Array.<(ResultGroup|RollResults|number|string)> |
boolean
resultGroup.useInTotal ⇒ 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
Param | Type |
---|---|
value | boolean |
number
resultGroup.value ⇒ 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
Param | Type |
---|---|
value | ResultGroup | RollResults | number | string |
Object
resultGroup.toJSON() ⇒ Return an object for JSON serialising.
This is called automatically when JSON encoding the object.
Kind: instance method of ResultGroup
string
resultGroup.toString() ⇒ Return the String representation of the object.
This is called automatically when casting the object to a string.
Kind: instance method of ResultGroup