The original provided data object which substitutes into attributes of the roll formula
Options which modify or describe the Roll
The identified terms of the Roll
An array of inner DiceTerms which were evaluated as part of the Roll evaluation
Store the original cleaned formula for the Roll, prior to any internal evaluation or simplification
Track whether this Roll instance has been evaluated or not. Once evaluated the Roll is immutable.
A Proxy environment for safely evaluating a string using only available Math functions
The HTML template path used to render a complete Roll object to the chat log
The HTML template used to render an expanded Roll tooltip to the chat log
Return an Array of the individual DiceTerm instances contained within this Roll.
Return a standardized representation for the displayed formula associated with this Roll.
The resulting arithmetic expression after rolls have been evaluated
Return the total result of the Roll expression if it has been evaluated.
Whether this Roll contains entirely deterministic terms or whether there is some randomness.
Get the default configured Roll class.
Alter the Roll expression 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.
Apply multiplication factor to numeric scalar terms
The altered Roll expression
Clone the Roll instance, returning a new Roll instance that has not yet been evaluated.
Execute the Roll, replacing dice and evaluating the total result
Options which inform how the Roll is evaluated
The evaluated Roll instance
Create a new Roll object using the original provided formula and data. Each roll is immutable, so this method returns a new Roll instance using the same data.
A new Roll object, rolled using the same formula and data
Render the tooltip HTML for a Roll instance
The rendered HTML tooltip as a string
Render a Roll instance to HTML
Options which affect how the Roll is rendered
The rendered HTML template as a string
Transform a Roll instance into a ChatMessage, displaying the roll result. This function can either create the ChatMessage directly, or return the data object that will be used to create.
The data object to use when creating the message
Additional options which modify the created message.
A promise which resolves to the created ChatMessage document if create is true, or the Object of prepared chatData otherwise.
Construct an inline roll link for this Roll.
Additional options to configure how the link is constructed.
Represent the data of the Roll as an object suitable for JSON serialization.
Structured data which can be serialized into JSON
Prepare the data structure used for the Roll. This is factored out to allow for custom Roll classes to do special data preparation using provided input.
Provided roll data
The prepared data object
Evaluate the roll asynchronously. A temporary helper method used to migrate behavior from 0.7.x (sync by default) to 0.9.x (async by default).
Options which inform how evaluation is performed
Evaluate the roll synchronously. A temporary helper method used to migrate behavior from 0.7.x (sync by default) to 0.9.x (async by default).
Options which inform how evaluation is performed
Safely evaluate the final total result for the Roll using its component terms.
The evaluated total
A factory method which constructs a Roll instance using the default configured Roll class.
The formula used to create the Roll instance
The constructed Roll instance
Transform an array of RollTerm objects into a cleaned string formula representation.
An array of terms to represent as a formula
The string representation of the formula
A sandbox-safe evaluation function to execute user-input code with access to scoped Math methods.
The input string expression
The numeric evaluated result
After parenthetical and arithmetic terms have been resolved, we need to simplify the remaining expression. Any remaining string terms need to be combined with adjacent non-operators in order to construct parsable terms.
An array of terms which is eligible for simplification
An array of simplified terms
Simulate a roll and evaluate the distribution of returned results
The Roll expression to simulate
The number of simulations
The rolled totals
Parse a formula by following an order of operations:
Step 1: Replace formula data Step 2: Split outer-most parenthetical groups Step 3: Further split outer-most dice pool groups Step 4: Further split string terms on arithmetic operators Step 5: Classify all remaining strings
The original string expression to parse
A data object used to substitute for attributes in the formula
A parsed array of RollTerm instances
Replace referenced data attributes in the roll formula with values from the provided data. Data references in the formula use the @attr syntax and would reference the corresponding attr key.
The original formula within which to replace
The data object which provides replacements
Validate that a provided roll formula can represent a valid
A candidate formula to validate
Is the provided input a valid dice formula?
Classify a remaining string term into a recognized RollTerm class
A remaining un-classified string
Options which customize classification
A classified RollTerm instance
Expand an inline roll element to display it's contained dice result as a tooltip
The inline-roll button
Collapse an expanded inline roll to conceal it's tooltip
The inline-roll button
Recreate a Roll instance using a provided data object
Unpacked data representing the Roll
A reconstructed Roll instance
Recreate a Roll instance using a provided JSON string
Serialized JSON data representing the Roll
A reconstructed Roll instance
Split a formula by identifying its outer-most parenthetical and math terms
The raw formula to split
An array of terms, split on parenthetical terms
Handle closing of a parenthetical term to create a MathTerm expression with a function and arguments
Split a formula by identifying its outer-most dice pool terms
The raw formula to split
An array of terms, split on parenthetical terms
Split a formula by identifying its outer-most groups using a certain group symbol like parentheses or brackets.
The raw formula to split
Options that configure how groups are split
An array of terms, split on dice pool terms
Split a formula by identifying arithmetic terms
The raw formula to split
An array of terms, split on arithmetic operators
Temporarily remove flavor text from a string formula allowing it to be accurately parsed.
The formula to extract
The cleaned formula and extracted flavor mapping
Restore flavor text to a string term
The string term possibly containing flavor symbols
The extracted flavors object
The restored term containing flavor text
An interface and API for constructing and evaluating dice rolls. The basic structure for a dice roll is a string formula and an object of data against which to parse it.
The string formula to parse
The data object against which to parse attributes within the formula
Attack with advantage