MathTerm

MathTerm

A type of RollTerm used to apply a function from the Math library.

Constructor

new MathTerm()

Extends

Members

_evaluated :boolean

Overrides:

An internal flag for whether the term has been evaluated

Type:
  • boolean

dice :Array.<DiceTerm>

An array of evaluated DiceTerm instances that should be bubbled up to the parent Roll

Type:

expression :string

Overrides:

A string representation of the formula expression for this RollTerm, prior to evaluation.

Type:
  • string

flavor :string

Overrides:

Optional flavor text which modifies and describes this term.

Type:
  • string

FLAVOR_REGEXP :RegExp

Overrides:

A regular expression which identifies term-level flavor text

Type:

FLAVOR_REGEXP_STRING :string

Overrides:

A regular expression pattern which identifies optional term-level flavor text

Type:
  • string

fn :string

The named function in the Math environment which should be applied to the term

Type:
  • string

formula :string

Overrides:

A string representation of the formula, including optional flavor text.

Type:
  • string

isDeterministic :boolean

Overrides:

Whether this term is entirely deterministic or contains some randomness.

Type:
  • boolean

isIntermediate :boolean

Overrides:

Is this term intermediate, and should be evaluated first as part of the simplification process?

Type:
  • boolean

options :object

Overrides:

An object of additional options which describes and modifies the term.

Type:
  • object

REGEXP :RegExp

Overrides:

A regular expression used to match a term of this type

Type:

result :number

The cached result of evaluating the method arguments

Type:
  • number

rolls :Array.<Roll>

The cached Roll instances for each function argument

Type:

SERIALIZE_ATTRIBUTES :Array.<string>

Overrides:

An array of additional attributes which should be retained when the term is serialized

Type:

terms :Array.<string>

An array of string argument terms for the function

Type:

total :number|string

Overrides:

A string or numeric representation of the final output for this term, after evaluation.

Type:
  • number | string

Methods

evaluate(optionsopt) → {RollTerm}

Overrides:

Evaluate the term, processing its inputs and finalizing its total.

Parameters:
Name Type Attributes Default Description
options object <optional>
{}

Options which modify how the RollTerm is evaluated

Properties
Name Type Attributes Default Description
minimize boolean <optional>
false

Minimize the result, obtaining the smallest possible value.

maximize boolean <optional>
false

Maximize the result, obtaining the largest possible value.

async boolean <optional>
false

Evaluate the term asynchronously, receiving a Promise as the returned value. This will become the default behavior in version 10.x

Returns:

The evaluated RollTerm

Type
RollTerm

toJSON() → {object}

Overrides:

Serialize the RollTerm to a JSON string which allows it to be saved in the database or embedded in text. This method should return an object suitable for passing to the JSON.stringify function.

Returns:
Type
object