Data used to create the Dice Term, including the following:
Optionalfaces?: number | RollThe number of faces on each die of this type, or a Roll instance that will be evaluated to a number.
The resolution method used to resolve DiceTerm.
Optionalmodifiers?: string[]An array of modifiers applied to the results
Optionalnumber?: number | RollThe number of dice of this term to roll, before modifiers are applied, or a Roll instance that will be evaluated to a number.
Optionaloptions?: objectAdditional options that modify the term
Optionalresults?: DiceTermResult[]An optional array of pre-cast results for the term
Internal_rootA reference to the Roll at the root of the evaluation tree.
Is this term intermediate, and should be evaluated first as part of the simplification process?
An Array of dice term modifiers which are applied
An object of additional options which describes and modifies the term.
The array of dice term results which have been rolled
Protected_facesThe number of faces on the die, or a Roll instance that will be evaluated to a number.
Protected_numberThe number of dice of this term to roll, before modifiers are applied, or a Roll instance that will be evaluated to a number.
StaticDENOMINATIONDefine the denomination string used to register this DiceTerm type in CONFIG.Dice.terms
StaticFLAVOR_A regular expression which identifies term-level flavor text
StaticFLAVOR_A regular expression pattern which identifies optional term-level flavor text
StaticMODIFIER_A regular expression used to separate individual modifiers
StaticMODIFIERSDefine the named modifiers that can be applied for this particular DiceTerm type.
StaticMODIFIERS_A regular expression pattern which captures the full set of term modifiers Anything until a space, group symbol, or arithmetic operator
StaticREGEXPA regular expression used to match a term of this type
StaticSERIALIZE_An array of additional attributes which should be retained when the term is serialized
The denomination of this DiceTerm instance.
An array of additional DiceTerm instances involved in resolving this DiceTerm.
A string representation of the formula expression for this RollTerm, prior to evaluation.
The number of faces on the die. Returns undefined if the faces are represented as a complex term that has not yet been evaluated.
Optional flavor text which modifies and describes this term.
A string representation of the formula, including optional flavor text.
Whether this term is entirely deterministic or contains some randomness.
The resolution method used to resolve this DiceTerm.
The number of dice of this term to roll. Returns undefined if the number is a complex term that has not yet been evaluated.
A reference to the RollResolver app being used to externally resolve this term.
A string or numeric representation of the final output for this term, after evaluation.
Return an array of rolled values which are still active within this term
InternalAsynchronously evaluate a single modifier command, recording it in the array of evaluated modifiers
The parsed modifier command
The full modifier request
InternalSequentially evaluate each dice roll modifier by passing the term to its evaluation function Augment or modify the results array.
Alter the DiceTerm by adding or multiplying the number of dice which are rolled
A factor to multiply. Dice are multiplied before any additions.
A number of dice to add. Dice are added after multiplication.
The altered term
Evaluate the term, processing its inputs and finalizing its total.
Optionaloptions: { allowStrings?: boolean; maximize?: boolean; minimize?: boolean } = {}Options which modify how the RollTerm is evaluated
OptionalallowStrings?: booleanIf true, string terms will not throw an error when evaluated.
Optionalmaximize?: booleanMaximize the result, obtaining the largest possible value.
Optionalminimize?: booleanMinimize the result, obtaining the smallest possible value.
Returns a Promise if the term is non-deterministic.
Get the CSS classes that should be used to display each rolled result
The rolled result
The desired classes
Return a string used as the label for each rolled result
The rolled result
The result label
Render the tooltip HTML for a Roll instance
The data object used to render the default tooltip template for this DiceTerm
Maps a randomly-generated value in the interval [0, 1) to a face value on the die.
A value to map. Must be in the interval [0, 1).
The face value.
Generate a random face value for this die using the configured PRNG.
Roll the DiceTerm by mapping a random uniform draw against the faces of the dice term.
Optionaloptions: { maximize?: boolean; minimize?: boolean } = {}Options which modify how a random result is produced
Optionalmaximize?: booleanMaximize the result, obtaining the largest possible value.
Optionalminimize?: booleanMinimize the result, obtaining the smallest possible value.
The produced result
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.
Protected_evaluateProtectedEvaluate this dice term asynchronously.
Optionaloptions: object = {}Options forwarded to inner Roll evaluation.
Protected_evaluateProtectedEvaluate deterministic values of this term synchronously.
Optionaloptions: { maximize?: boolean; minimize?: boolean; strict?: boolean } = {}Optionalmaximize?: booleanForce the result to be maximized.
Optionalminimize?: booleanForce the result to be minimized.
Optionalstrict?: booleanThrow an error if attempting to evaluate a die term in a way that cannot be done synchronously.
Protected_rollProtectedGenerate a roll result value for this DiceTerm based on its fulfillment method.
Optionaloptions: object = {}Options forwarded to the fulfillment method handler.
Returns a Promise that resolves to the fulfilled number, or undefined if it could not be fulfilled.
Static_applyA reusable helper function to handle the identification and deduction of failures
Static_applyA reusable helper function to handle the identification and deduction of failures
Static_fromDefine term-specific logic for how a de-serialized data object is restored as a functional RollTerm
The de-serialized term data
The re-constructed RollTerm object
Static_keepA helper method to modify the results array of a dice term by flagging certain results are kept or dropped.
The results array
The number to keep or drop
Optionaloptions: { highest?: boolean; keep?: boolean } = {}Optionalhighest?: booleanKeep the highest?
Optionalkeep?: booleanKeep results?
The modified results array
StaticcompareA helper comparison function. Returns a boolean depending on whether the result compares favorably against the target.
The result being compared
The comparison operator in [=,<,<=,>,>=]
The target value
Is the comparison true?
StaticfromConstruct a RollTerm from a provided data object
Provided data from an un-serialized term
The constructed RollTerm
StaticfromJSONReconstruct a RollTerm instance from a provided JSON string
A serialized JSON representation of a DiceTerm
A reconstructed RollTerm from the provided JSON
StaticfromConstruct a term of this type given a matched regular expression array.
The matched regular expression array
The constructed term
StaticfromStaticisDetermine if evaluating a given RollTerm with certain evaluation options can be done so deterministically.
The term.
Optionaloptions: { maximize?: boolean; minimize?: boolean } = {}Options for evaluating the term.
Optionalmaximize?: booleanForce the result to be maximized.
Optionalminimize?: booleanForce the result to be minimized.
StaticmatchDetermine whether a string expression matches this type of term
The expression to parse
Optionaloptions: { imputeNumber?: boolean } = {}Additional options which customize the match
OptionalimputeNumber?: booleanAllow the number of dice to be optional, i.e. "d6"
An abstract base class for any type of RollTerm which involves randomized input from dice, coins, or other devices.