[−][src]Enum critfail::Roll
Any kind of roll—either a check, damage, or attack roll.
This struct is useful when parsing a roll expression if you don't know what type of roll expression it will be.
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"
Variants
Check(Check)
A Roll
containing a Check
roll.
Damage(Damage)
A Roll
containing a Damage
roll.
Attack(Attack)
A Roll
containing an Attack
roll.
Implementations
impl Roll
[src]
pub fn is_check(&self) -> bool
[src]
Return true if this Roll
is a check roll.
use critfail::{RollExpression, Roll}; assert_eq!(Roll::new("r+3").unwrap().is_check(), true); assert_eq!(Roll::new("2d8+5").unwrap().is_check(), false); assert_eq!(Roll::new("r+3?2d8+5").unwrap().is_check(), false);
pub fn is_damage(&self) -> bool
[src]
Return true if this Roll
is a damage roll.
use critfail::{RollExpression, Roll}; assert_eq!(Roll::new("r+3").unwrap().is_damage(), false); assert_eq!(Roll::new("2d8+5").unwrap().is_damage(), true); assert_eq!(Roll::new("r+3?2d8+5").unwrap().is_damage(), false);
pub fn is_attack(&self) -> bool
[src]
Return true if this Roll
is an attack roll.
use critfail::{RollExpression, Roll}; assert_eq!(Roll::new("r+3").unwrap().is_attack(), false); assert_eq!(Roll::new("2d8+5").unwrap().is_attack(), false); assert_eq!(Roll::new("r+3?2d8+5").unwrap().is_attack(), true);
Trait Implementations
impl Clone for Roll
[src]
impl Debug for Roll
[src]
impl From<Attack> for Roll
[src]
impl From<Check> for Roll
[src]
impl From<Damage> for Roll
[src]
impl FromStr for Roll
[src]
type Err = ParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl PartialEq<Roll> for Roll
[src]
impl RollExpression for Roll
[src]
type Outcome = RollOutcome
The roll result type should implement both Display and Debug. Display should print out a consise result for the roll, and Debug should print out the details (eg the value for each rolled die). Read more
fn roll(&self) -> Self::Outcome
[src]
fn new(expression: &str) -> Result<Self, ParseError>
[src]
impl StructuralPartialEq for Roll
[src]
Auto Trait Implementations
impl RefUnwindSafe for Roll
impl Send for Roll
impl Sync for Roll
impl Unpin for Roll
impl UnwindSafe for Roll
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,