Struct d20::Roll
[−]
[src]
pub struct Roll { pub drex: String, pub values: Vec<(DieRollTerm, Vec<i8>)>, pub total: i32, }
Represents the results of an evaluated die roll expression.
The Roll
struct contains the original die roll expression passed to the roll_dice()
function.
The list of values
will always be a vector containing at least one element because roll
expressions are not valid without at least 1 term. Each resulting value is a tuple containing
the parsed DieRollTerm
and a vector of values. For DieRollTerm::Modifier
terms, this will be a single-element
vector containing the modifier value. For DieRollTerm::DieRoll
terms, this will be a vector
containing the results of each die roll.
The total
field contains the net result of evaluating the entire roll expression.
You can evaluate a roll expression (perform a roll) mutliple times by converting it into an iterator.
Fields
drex: String
A die roll expression conforming to the format specification
values: Vec<(DieRollTerm, Vec<i8>)>
The results of evaluating each term in the expression
total: i32
The net final result of evaluating all terms in the expression
Trait Implementations
impl Debug for Roll
[src]
impl Display for Roll
[src]
Formats roll results, including die rolls, in a human-readable string.
For example, if the original expression was 3d6+5
, formatting the Roll
struct
might result in the following text:
3d6[3,4,6]+5 (Total: 18)
impl IntoIterator for Roll
[src]
Converts an evaluated roll expression into an iterator, allowing the expression to be evaluated (including re-rolling of dice) multiple times.