Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • DiceMod

Index

Constructors

constructor

  • new DiceMod(modExpr?: string): DiceMod
  • throws

    {Error} Thrown when any part of modExpr cannot be parsed.

    Parameters

    • Optional modExpr: string

      The mod expression to create the DiceMod from.

    Returns DiceMod

Accessors

compounding

  • get compounding(): string

compoundingPlaintext

  • get compoundingPlaintext(): string

compoundingProperties

  • get compoundingProperties(): Types.ICompoundingProps
  • The raw properties for compounding, or null if this modifier does not have a compounding clause.

    Returns Types.ICompoundingProps

exploding

  • get exploding(): string

explodingPlaintext

  • get explodingPlaintext(): string

explodingProperties

  • get explodingProperties(): Types.IExplodingProps
  • The raw properties for exploding, or null if this modifier does not have an exploding clause.

    Returns Types.IExplodingProps

keepDrop

  • get keepDrop(): string

keepDropPlaintext

  • get keepDropPlaintext(): string

keepDropProperties

  • get keepDropProperties(): Types.IKeepDropProps
  • The raw properties for keepDrop, or null if this modifier does not have a keepDrop clause.

    Returns Types.IKeepDropProps

penetrating

  • get penetrating(): string

penetratingPlaintext

  • get penetratingPlaintext(): string

penetratingProperties

  • get penetratingProperties(): Types.IPenetratingProps
  • The raw properties for penetrating, or null if this modifier does not have a penetrating clause.

    Returns Types.IPenetratingProps

reroll

  • get reroll(): string

rerollPlaintext

  • get rerollPlaintext(): string

rerollProperties

  • get rerollProperties(): Types.IRerollProps[]
  • The raw properties for reroll, or null if this modifier does not have a reroll clause.

    Returns Types.IRerollProps[]

sort

  • get sort(): string

sortPlaintext

  • get sortPlaintext(): string

sortProperties

  • get sortProperties(): Types.ISortProps
  • The raw properties for sort, or null if this modifier does not have a sort clause.

    Returns Types.ISortProps

successes

  • get successes(): string

successesPlaintext

  • get successesPlaintext(): string

successesProperties

  • get successesProperties(): Types.ISuccessFailProps
  • The raw properties of successes, or null if this modifier does not have a successes clause.

    Returns Types.ISuccessFailProps

Static Protected explodeModRegExpr

  • get explodeModRegExpr(): RegExp
  • The RegExp used for parsing exploding, compounding, and penetrating.

    Returns RegExp

Static Protected keepDropModRegExp

  • get keepDropModRegExp(): RegExp

Static maxN

  • get maxN(): number
  • The maximum allowed value of n for a dice mod, which is equal to the largest representable integer in JavaScript (9007199254740991, or Number.MAX_SAFE_INTEGER in ES6).

    Returns number

Static Protected rerollModRegExp

  • get rerollModRegExp(): RegExp

Static Protected sortModRegExp

  • get sortModRegExp(): RegExp

Static Protected successesModRegExpr

  • get successesModRegExpr(): RegExp
  • The RegExp used for parsing successes and failures.

    Returns RegExp

Methods

modResult

  • modResult(result: number[]): number
  • A dice has been rolled and there are no more rolls to make. Modify the final result in place if necessary, and return the combined result of the rolls.

    Parameters

    • result: number[]

      The result array to modify.

    Returns number

    The combined total of the roll.

rolled

  • rolled(roll: number, result: number[], dice: Dice): void
  • Apply modifiers to a dice that was just rolled and add it to the result in place if necessary.

    Parameters

    • roll: number

      The value that was just rolled.

    • result: number[]

      The result object.

    • dice: Dice

      The dice that was used to roll the value.

    Returns void

toString

  • toString(): string
  • The combined value of the modifier as a string.

    Returns string

toStringPlaintext

  • toStringPlaintext(): string

Static comparePoint

  • comparePoint(cp: Types.ComparePoint, n: number, value: number): boolean
  • throws

    {Error} Thrown if cp is not a compare point.

    example

    DiceMod.comparePoint('>', 3, 4); // => true

    example

    DiceMod.comparePoint('>', 3, 3); // => true

    example

    DiceMod.comparePoint('>', 3, 2); // => false

    Parameters

    • cp: Types.ComparePoint

      The compare point to use.

    • n: number

      The numeric value of the compare point.

    • value: number

      The number to compare against the compare point.

    Returns boolean

    True if value "matches" the compare point.

Static comparePointToString

  • comparePointToString(cp: Types.ComparePoint): string
  • throws

    {Error} If the cp param is not a compare point.

    Parameters

    • cp: Types.ComparePoint

      The compare point to translate.

    Returns string

    The english plaintext representation of the compare point.

Static Protected sortAscComparator

  • sortAscComparator(a: number, b: number): number
  • Compare function used to sort numbers ascending.

    Parameters

    • a: number
    • b: number

    Returns number

Static Protected sortDesComparator

  • sortDesComparator(a: number, b: number): number
  • Compare function used to sort numbers descending.

    Parameters

    • a: number
    • b: number

    Returns number

Generated using TypeDoc