EN605.607.81.SP22_ASDM_Project/front_end/src/random_helper.rs
Stephen Seo 9e9bb0758c Fix rand not compilable for wasm, impl game logic
"rand" crate was not compilable for wasm-unknown-unknown target, so an
alternative "oorandom" crate was substituted in.

Basic game win/draw detection logic added.
2022-03-09 16:26:14 +09:00

13 lines
296 B
Rust

use oorandom::Rand32;
use std::time::{SystemTime, UNIX_EPOCH};
pub fn get_seeded_random() -> Result<Rand32, String> {
let now = SystemTime::now();
let duration = now
.duration_since(UNIX_EPOCH)
.map_err(|e| format!("{}", e))?;
Ok(Rand32::new(duration.as_secs()))
}