[]Struct rltk::RandomNumberGenerator

pub struct RandomNumberGenerator { /* fields omitted */ }

Methods

impl RandomNumberGenerator

pub fn new() -> RandomNumberGenerator

Creates a new RNG from a randomly generated seed

pub fn seeded(seed: u64) -> RandomNumberGenerator

Creates a new RNG from a specific seed

pub fn rand<T>(&mut self) -> T where
    Standard: Distribution<T>, 

Returns a random value of whatever type you specify

pub fn range<T>(&mut self, min: T, max: T) -> T where
    T: SampleUniform

Returns a random value in the specified range, of type specified at the call site. This is INCLUSIVE of the first parameter, and EXCLUSIVE of the second. So range(1,6) will give you numbers from 1 to 5.

pub fn roll_dice(&mut self, n: i32, die_type: i32) -> i32

Rolls dice, using the classic 3d6 type of format: n is the number of dice, die_type is the size of the dice.

pub fn next_u64(&mut self) -> u64

pub fn roll(&mut self, dice: DiceType) -> i32

pub fn roll_str<S>(&mut self, dice: S) -> Result<i32, DiceParseError> where
    S: ToString

pub fn random_slice_index<T>(&mut self, slice: &[T]) -> Option<usize>

pub fn random_slice_entry<T>(&mut self, slice: &'a [T]) -> Option<&'a T>

Auto Trait Implementations

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,