diff --git a/30_Cube/rust/Cargo.toml b/30_Cube/rust/Cargo.toml new file mode 100644 index 00000000..3b1d02f5 --- /dev/null +++ b/30_Cube/rust/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "rust" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rand = "0.8.5" diff --git a/30_Cube/rust/src/game.rs b/30_Cube/rust/src/game.rs new file mode 100644 index 00000000..e4f721f7 --- /dev/null +++ b/30_Cube/rust/src/game.rs @@ -0,0 +1,17 @@ +pub type Position = (u8, u8, u8); + +pub struct Game { + wallet: u8, + bet: u8, + landmines: Vec, + player: Position, +} + +impl Game { + pub fn new() -> Self { + let mut landmines = Vec::new(); + + let mut m: Position = (0, 0, 0); + while !landmines.contains(&m) {} + } +} diff --git a/30_Cube/rust/src/main.rs b/30_Cube/rust/src/main.rs new file mode 100644 index 00000000..6297fcdf --- /dev/null +++ b/30_Cube/rust/src/main.rs @@ -0,0 +1,6 @@ +mod game; +mod util; + +fn main() { + println!("Hello, world!"); +} diff --git a/30_Cube/rust/src/util.rs b/30_Cube/rust/src/util.rs new file mode 100644 index 00000000..57c9a399 --- /dev/null +++ b/30_Cube/rust/src/util.rs @@ -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::(){ + + } + } + } +}