Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "parser"

Index

Variables

Const opReg

opReg: RegExp = new RegExp("([+-/*]\\d\\w+)")

Const toRollReg

toRollReg: RegExp = new RegExp("(\\dd\\d+!?)")

Const xReg

xReg: RegExp = new RegExp("(-[HL])")

Functions

evaluate

  • evaluate(expression: string): number
  • Evaluates standard dice notation and returns the result of the rolls

    Parameters

    • expression: string

      The dice notation string to parse

    Returns number

    The result of the parsed die roll.

getDice

  • getDice(expression: string): string
  • Returns a string representation of dice to be rolled

    remarks

    Expects to see an expression like 4d6 or 1d20. Will throw an error on bad input

    Parameters

    • expression: string

      The string to parse for a dice expression

    Returns string

    A string representation of dice to be rolled

getDrop

  • getDrop(expression: string): string
  • Returns a string representation of die to be drop

    Parameters

    • expression: string

      The string to parse for a drop expression

    Returns string

    A string representation of dice to be dropped

getMatch

  • getMatch(regex: RegExp, expression: string): string
  • Parameters

    • regex: RegExp
    • expression: string

    Returns string

getOperator

  • getOperator(expression: string): string
  • Returns a string representation of a dice operator

    Parameters

    • expression: string

      The string to parse for a operator expression

    Returns string

    A string representation of operator to apply

processDrop

  • processDrop(expression: string, results: Die[]): Die[]

processOperator

  • processOperator(expression: string, total: number): number
  • Parameters

    • expression: string
    • total: number

    Returns number

Generated using TypeDoc