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

KeepModifier

KeepModifier ⇐ Modifier

A KeepModifier will "keep" dice from a roll, dropping (Remove from total calculations) all others.

Kind: global class
Extends: Modifier
See: DropModifier for the opposite of this modifier

  • KeepModifier ⇐ Modifier
    • new KeepModifier([end], [qty])
    • .order : number
    • .end ⇒ string
    • .end
    • .name ⇒ string
    • .notation ⇒ string
    • .qty ⇒ number
    • .qty
    • .rangeToDrop(_results) ⇒ Array.<number>
    • .run(results, _context) ⇒ ResultGroup | RollResults
    • .toJSON() ⇒ Object

new KeepModifier([end], [qty])

Create a KeepModifier instance

Throws:

  • RangeError End must be one of 'h' or 'l'
  • TypeError qty must be a positive integer
ParamTypeDefaultDescription
[end]string"h"Either `h
[qty]number1The amount dice to keep

keepModifier.order : number

The default modifier execution order.

Kind: instance property of KeepModifier

keepModifier.end ⇒ string

Which end the rolls should be kept ("h" = High, "l" = Low).

Kind: instance property of KeepModifier
Returns: string - 'h' or 'l'

keepModifier.end

Set which end the rolls should be kept ("h" = High, "l" = Low).

Kind: instance property of KeepModifier
Throws:

  • RangeError End must be one of 'h' or 'l'
ParamTypeDescription
valuestringEither 'h' or 'l'

keepModifier.name ⇒ string

The name of the modifier.

Kind: instance property of KeepModifier
Returns: string - 'keep-l' or 'keep-h'

keepModifier.notation ⇒ string

The modifier's notation.

Kind: instance property of KeepModifier

keepModifier.qty ⇒ number

The quantity of dice that should be kept.

Kind: instance property of KeepModifier

keepModifier.qty

Set the quantity of dice that should be kept.

Kind: instance property of KeepModifier
Throws:

  • TypeError qty must be a positive finite integer
ParamType
valuenumber

keepModifier.rangeToDrop(_results) ⇒ Array.<number>

Determine the start and end (end exclusive) range of rolls to drop.

Kind: instance method of KeepModifier
Returns: Array.<number> - The min / max range to drop

ParamTypeDescription
_resultsRollResultsThe results to drop from

keepModifier.run(results, _context) ⇒ ResultGroup | RollResults

Run the modifier on the results.

Kind: instance method of KeepModifier
Returns: ResultGroup | RollResults - The modified results

ParamTypeDescription
resultsResultGroup | RollResultsThe results to run the modifier against
_contextStandardDice | RollGroupThe object that the modifier is attached to

keepModifier.toJSON() ⇒ Object

Return an object for JSON serialising.

This is called automatically when JSON encoding the object.

Kind: instance method of KeepModifier

Edit this page
Last Updated: 07/02/2026, 21:45
Prev
ExplodeModifier
Next
MaxModifier