1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! Evaluation and rolling of D&D 5e die roll expressions.
//!
//! The `RollExpression` trait provides methods for dealing with the
//! various kinds of rolls. `Roll` provides the simplest text-in,
//! text-out interface for rolling expressions an printing the result
//! regardless of the type of roll.
//!
//! ```
//! use critfail::{RollExpression, Roll};
//!
//! let check = Roll::new("r-3").unwrap();
//! let check_outcome = check.roll();
//! print!("{}", check_outcome); // eg. "11"
//! print!("{:?}", check_outcome); // eg. "(14)-3"
//!
//! let damage = Roll::new("2d8+6").unwrap();
//! let damage_outcome = damage.roll();
//! print!("{}", damage_outcome); // eg. "13"
//! print!("{:?}", damage_outcome); // eg. "[2+5]+6"
//!
//! let attack = Roll::new("r+1?2d6+4").unwrap();
//! let attack_outcome = attack.roll();
//! print!("{}", attack_outcome); // eg. "10 ? 16"
//! print!("{:?}", attack_outcome); // eg. "(9)+1 ? [6+6]+4"
//! ```
//!
//! In order to handle the outcome of a `Roll` programatically, roll
//! expressions are split into `Check` rolls, `Damage` rolls, and
//! `Attack` rolls, each with their own outcome type which provides
//! methods for determining the score and makeup of the results for
//! each.
//!
//! # Features
//! * `wasm-bindgen`: Enable this when compiling for wasm32 targets, or
//! random number generation won't work.
extern crate lazy_static;
use fmt;
use FromStr;
pub use ;
pub use ;
pub use ;
pub use ParseError;
pub use ModifiersOutcome;
pub use OutcomePart;
pub use ;
/// The number type that is used when reporting the score of a roll
pub type Score = i32;
/// The number type that is used for specifying the number of sides on a
/// die
pub type Sides = i32;
/// Used for structs defining a set of dice that can be rolled.