This commit is contained in:
Uğur Küpeli
2022-05-07 11:15:31 +03:00
parent 9dd1c0e218
commit e9366d3c0c
4 changed files with 55 additions and 0 deletions

23
30_Cube/rust/src/util.rs Normal file
View File

@@ -0,0 +1,23 @@
pub fn get_random_position() -> crate::game::Position {
(get_random_axis(), get_random_axis(), get_random_axis())
}
fn get_random_axis() -> u8 {
rand::Rng::gen_range(&mut rand::thread_rng(), 1..=3)
}
pub fn prompt(yes_no: bool, msg: &str) -> (u8, bool) {
loop {
let mut input = String::new();
std::io::stdin()
.read_line(&mut input)
.expect("~~Failed reading line!~~");
let input = input.trim();
if yes_no {
if let Ok(n) = input.parse::<u8>(){
}
}
}
}