Constructor
new RollTerm()
Members
_evaluated :boolean
An internal flag for whether the term has been evaluated
Type:
- boolean
expression :string
A string representation of the formula expression for this RollTerm, prior to evaluation.
Type:
- string
flavor :string
Optional flavor text which modifies and describes this term.
Type:
- string
FLAVOR_REGEXP :RegExp
A regular expression which identifies term-level flavor text
Type:
FLAVOR_REGEXP_STRING :string
A regular expression pattern which identifies optional term-level flavor text
Type:
- string
formula :string
A string representation of the formula, including optional flavor text.
Type:
- string
isDeterministic :boolean
Whether this term is entirely deterministic or contains some randomness.
Type:
- boolean
isIntermediate :boolean
Is this term intermediate, and should be evaluated first as part of the simplification process?
Type:
- boolean
options :object
An object of additional options which describes and modifies the term.
Type:
- object
REGEXP :RegExp
A regular expression used to match a term of this type
Type:
SERIALIZE_ATTRIBUTES :Array.<string>
An array of additional attributes which should be retained when the term is serialized
Type:
- Array.<string>
total :number|string
A string or numeric representation of the final output for this term, after evaluation.
Type:
- number | string
Methods
(protected, static) _fromData(data) → {RollTerm}
Define term-specific logic for how a de-serialized data object is restored as a functional RollTerm
Parameters:
Name | Type | Description |
---|---|---|
data |
object | The de-serialized term data |
Returns:
The re-constructed RollTerm object
- Type
- RollTerm
(static) fromData(data) → {RollTerm}
Construct a RollTerm from a provided data object
Parameters:
Name | Type | Description |
---|---|---|
data |
object | Provided data from an un-serialized term |
Returns:
The constructed RollTerm
- Type
- RollTerm
(static) fromJSON(json) → {RollTerm}
Reconstruct a RollTerm instance from a provided JSON string
Parameters:
Name | Type | Description |
---|---|---|
json |
string | A serialized JSON representation of a DiceTerm |
Returns:
A reconstructed RollTerm from the provided JSON
- Type
- RollTerm
evaluate(optionsopt) → {RollTerm}
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
|
Returns:
The evaluated RollTerm
- Type
- RollTerm
toJSON() → {object}
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