RollResult class
The result of rolling a dice expression.
A RollResult is modeled as a binary tree. The dice expression is parsed into a DiceExpression and when evaluated the results should (mostly) reflect the structure of AST.
In general, most users will just care about the root node of the tree. But, depending on the information you want from the evaluated dice rolls, you may need to traverse the tree to inspect all the events.
Constructors
-
RollResult({required String expression, int ndice = 0, int nsides = 0, List<
int> results = const [], Map<String, Object> metadata = const {}, RollResult? left, RollResult? right}) -
RollResult.fromRollResult(RollResult other, {required String expression, int? ndice, int? nsides, List<
int> ? results, Map<String, Object> metadata = const {}, RollResult? left, RollResult? right}) -
factory constructor to merge
other
with the params of this function and produce a new RollResult.factory
Properties
- expression → String
-
the parsed expression
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- left → RollResult?
-
final
-
metadata
→ Map<
String, Object> -
any metadata the operation may have recorded
final
- ndice → int
-
number of dice rolled. may be zero if complex expression or arithmetic result
final
- nsides → int
-
number of sides. may be zero if complex expression or arithmetic result
final
-
props
→ List<
Object?> -
The list of properties that will be used to determine whether
two instances are equal.
no setter
-
results
→ List<
int> -
the results of the evaluating the expression
final
- right → RollResult?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stringify → bool?
-
If set to
true
, the toString method will be overridden to output this instance's props.no setterinherited - total ↔ int
-
sum of results
getter/setter pair
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, Object?> -
toString(
) → String -
A string representation of this object.
override
-
totalOrDefault(
int defaultCb()) → int -
Get the total, or if results are empty return result of calling
defaultCb
.
Operators
-
operator *(
RollResult other) → RollResult - multiplication operator for RollResult.
-
operator +(
RollResult other) → RollResult - addition operator for RollResult.
-
operator -(
RollResult other) → RollResult - subtraction operator for RollResult.
-
operator ==(
Object other) → bool -
The equality operator.
inherited