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

17
30_Cube/rust/src/game.rs Normal file
View File

@@ -0,0 +1,17 @@
pub type Position = (u8, u8, u8);
pub struct Game {
wallet: u8,
bet: u8,
landmines: Vec<Position>,
player: Position,
}
impl Game {
pub fn new() -> Self {
let mut landmines = Vec::new();
let mut m: Position = (0, 0, 0);
while !landmines.contains(&m) {}
}
}

6
30_Cube/rust/src/main.rs Normal file
View File

@@ -0,0 +1,6 @@
mod game;
mod util;
fn main() {
println!("Hello, world!");
}

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>(){
}
}
}
}