Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

    A type of RollTerm used to denote and perform an arithmetic operation.

    Hierarchy (View Summary)

    Index

    Properties

    _root: Roll

    A reference to the Roll at the root of the evaluation tree.

    isIntermediate: boolean = false

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

    operator: string

    The term's operator value.

    options: object

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

    FLAVOR_REGEXP: RegExp = ...

    A regular expression which identifies term-level flavor text

    FLAVOR_REGEXP_STRING: string = "(?:\\[([^\\]]+)\\])"

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

    OPERATORS: string[] = ...

    An array of operators which represent arithmetic operations

    PRECEDENCE: Readonly<Record<string, number>> = ...

    An object of operators with their precedence values.

    REGEXP: RegExp = ...
    SERIALIZE_ATTRIBUTES: string[] = ...

    Accessors

    • get expression(): string

      Returns string

    • get flavor(): string

      Returns string

    • get formula(): string

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

      Returns string

    • get isDeterministic(): boolean

      Whether this term is entirely deterministic or contains some randomness.

      Returns boolean

    • get resolver(): RollResolver

      A reference to the RollResolver app being used to externally resolve this term.

      Returns RollResolver

    • get total(): string

      Returns string

    Methods

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

      Parameters

      • Optionaloptions: { allowStrings?: boolean; maximize?: boolean; minimize?: boolean } = {}

        Options which modify how the RollTerm is evaluated

        • OptionalallowStrings?: boolean

          If true, string terms will not throw an error when evaluated.

        • Optionalmaximize?: boolean

          Maximize the result, obtaining the largest possible value.

        • Optionalminimize?: boolean

          Minimize the result, obtaining the smallest possible value.

      Returns RollTerm | Promise<RollTerm>

      Returns a Promise if the term is non-deterministic.

    • 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 RollTermData

    • Protected

      Evaluate the term.

      Parameters

      • Optionaloptions: object = {}

        Options which modify how the RollTerm is evaluated, see RollTerm#evaluate

      Returns RollTerm | Promise<RollTerm>

      Returns a Promise if the term is non-deterministic.

    • Reconstruct a RollTerm instance from a provided JSON string

      Parameters

      • json: string

        A serialized JSON representation of a DiceTerm

      Returns RollTerm

      A reconstructed RollTerm from the provided JSON

    • Determine if evaluating a given RollTerm with certain evaluation options can be done so deterministically.

      Parameters

      • term: RollTerm

        The term.

      • Optionaloptions: { maximize?: boolean; minimize?: boolean } = {}

        Options for evaluating the term.

        • Optionalmaximize?: boolean

          Force the result to be maximized.

        • Optionalminimize?: boolean

          Force the result to be minimized.

      Returns boolean