Add new rng module
This commit is contained in:
parent
161ed3f4b9
commit
206f012729
@ -18,6 +18,7 @@ mod random_table;
|
||||
mod raws;
|
||||
mod rect;
|
||||
mod rex_assets;
|
||||
mod rng;
|
||||
mod saveload_system;
|
||||
mod spatial;
|
||||
mod spawner;
|
||||
|
18
src/rng.rs
Normal file
18
src/rng.rs
Normal file
@ -0,0 +1,18 @@
|
||||
use ::rltk::prelude::*;
|
||||
use std::sync::Mutex;
|
||||
|
||||
lazy_static! {
|
||||
static ref RNG: Mutex<RandomNumberGenerator> = Mutex::new(RandomNumberGenerator::new());
|
||||
}
|
||||
|
||||
pub fn reseed(seed: u64) {
|
||||
*RNG.lock().unwrap() = RandomNumberGenerator::seeded(seed);
|
||||
}
|
||||
|
||||
pub fn roll_dice(n: i32, die_type: i32) -> i32 {
|
||||
RNG.lock().unwrap().roll_dice(n, die_type)
|
||||
}
|
||||
|
||||
pub fn range(min: i32, max: i32) -> i32 {
|
||||
RNG.lock().unwrap().range(min, max)
|
||||
}
|
Loading…
Reference in New Issue
Block a user