[][src]Struct cute_dnd_dice::Roll

pub struct Roll {
    pub num: u16,
    pub faces: NonZeroU16,
    pub extra: Modifier,
}

D&D Roll representation

Fields

num: u16

Number of dices

faces: NonZeroU16

Number of faces on dice

extra: Modifier

Bonus to roll

Implementations

impl Roll[src]

pub const fn new(num: u16, faces: NonZeroU16, extra: Modifier) -> Self[src]

pub fn from_str(text: &str) -> Result<Self, ParseError>[src]

Attempts to parse Roll from string [num]d<faces> [+ <extra>]

pub fn min(&self) -> u16[src]

Returns minimum possible value.

pub fn max(&self) -> u16[src]

Returns maximum possible value.

pub fn roll_with(&self, fun: fn() -> u64) -> u16[src]

Rolls using specified callable to generate random numbers.

fn my_random() -> u64 {
    0xff
}

let roll = cute_dnd_dice::Roll::from_str("2d20+1").unwrap();
assert_eq!(roll.roll_with(my_random), 3);

pub fn roll(&self) -> u16[src]

Calculates roll with default random source.

It provides decent uniform distribution.

Trait Implementations

impl Debug for Roll[src]

impl Display for Roll[src]

Auto Trait Implementations

impl Send for Roll

impl Sync for Roll

impl Unpin for Roll

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.