RPG Dice RollerRPG Dice Roller
Home
Guide
API
  • Contributing
  • Code of Conduct
GitHub
Home
Guide
API
  • Contributing
  • Code of Conduct
GitHub
  • API

    • Introduction
    • ComparePoint
    • Description
    • DiceRoll
    • DiceRoller
    • RollGroup
  • dice

    • FudgeDice
    • PercentileDice
    • StandardDice
  • exceptions

    • CompareOperatorError
    • DataFormatError
    • DieActionValueError
    • NotationError
    • RequiredArgumentError
  • modifiers

    • ComparisonModifier
    • CriticalFailureModifier
    • CriticalSuccessModifier
    • DropModifier
    • ExplodeModifier
    • KeepModifier
    • MaxModifier
    • MinModifier
    • Modifier
    • ReRollModifier
    • SortingModifier
    • TargetModifier
    • UniqueModifier
    • modifier-flags
  • parser

    • Parser
  • results

    • ResultGroup
    • RollResult
    • RollResults
  • traits

    • HasDescription
  • utilities

    • ExportFormats
    • NumberGenerator
    • math
    • utils

RollGroup

RollGroup

A RollGroup is a group of one or more "sub-rolls".

A sub-roll is just simple roll notation (e.g. 4d6, 2d10*3, 5/10d20)

Kind: global class
Since: 4.5.0

  • RollGroup
    • new RollGroup([expressions], [modifiers], [description])
    • .expressions ⇒ Array.<Array.<(StandardDice|string|number)>>
    • .expressions
    • .modifiers ⇒ Map.<string, Modifier> | null
    • .modifiers
    • .notation ⇒ string
    • .roll() ⇒ ResultGroup
    • .toJSON() ⇒ Object
    • .toString() ⇒ string

new RollGroup([expressions], [modifiers], [description])

Create a RollGroup instance.

ParamTypeDefaultDescription
[expressions]Array.<Array.<(StandardDice|string|number)>>[]List of sub-rolls
[modifiers]Map.<string, Modifier> | Array.<Modifier> | Object | null[]The modifiers that affect the group
[description]Description | string | nullThe roll description.

Example (`{4d6+4, 2d%/5}k1`)

const expressions = [
  [
    new StandardDice(6, 4),
    '+',
    4,
  ],
  [
    new PercentileDice(2),
    '/',
    5,
  ],
];

const modifiers = [
  new KeepModifier(),
];

const group = new RollGroup(expressions, modifiers);

rollGroup.expressions ⇒ Array.<Array.<(StandardDice|string|number)>>

The sub-roll expressions in the group.

Kind: instance property of RollGroup

rollGroup.expressions

Set the sub-roll expressions in the group.

Kind: instance property of RollGroup
Throws:

  • TypeError Expressions must be an array of arrays
  • TypeError Sub expressions cannot be empty
  • TypeError Sub expression items must be Dice, numbers, or strings
ParamType
expressionsArray.<Array.<(StandardDice|string|number)>>

rollGroup.modifiers ⇒ Map.<string, Modifier> | null

The modifiers that affect the object.

Kind: instance property of RollGroup

rollGroup.modifiers

Set the modifiers that affect this group.

Kind: instance property of RollGroup
Throws:

  • TypeError Modifiers should be a Map, array of Modifiers, or an Object
ParamType
valueMap.<string, Modifier> | Array.<Modifier> | Object | null

rollGroup.notation ⇒ string

The group notation. e.g. {4d6, 2d10+3}k1.

Kind: instance property of RollGroup

rollGroup.roll() ⇒ ResultGroup

Run the sub-roll expressions for the group.

Kind: instance method of RollGroup
Returns: ResultGroup - The results of the sub-rolls
Example (`{4d6+4/1d6, 2d10/3}k1`)

ResultGroup {
  results: [
    // sub-roll 1 - 4d6+4/1d6
    ResultGroup {
      results: [
        RollResults {
          rolls: [
            RollResult {
              value: 2
            },
            RollResult {
              value: 5
            },
            RollResult {
              value: 4
            },
            RollResult {
              value: 1
            }
          ]
        },
        '+',
        4,
        '/',
        RollResults {
          rolls: [
            RollResult {
              value: 4
            }
          ]
        }
      ]
    },
    // sub-roll 2 - 2d10/3
    ResultGroup {
      results: [
        RollResults {
          rolls: [
            RollResults {
              4
            },
            RollResults {
              9
            }
          ]
        },
        '/',
        3
      ]
    }
  ]
}

rollGroup.toJSON() ⇒ Object

Return an object for JSON serialising.

This is called automatically when JSON encoding the object.

Kind: instance method of RollGroup

rollGroup.toString() ⇒ string

Return the String representation of the object.

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

Kind: instance method of RollGroup
See: notation

Edit this page
Last Updated: 07/02/2026, 21:45
Prev
DiceRoller