diff --git a/Cargo.lock b/Cargo.lock index b26aa85..cfdad83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -292,6 +292,7 @@ dependencies = [ name = "rs48-telnet" version = "0.1.0" dependencies = [ + "rand", "rs48_lib", "termion 2.0.1", "tokio", diff --git a/Cargo.toml b/Cargo.toml index 161c9e1..75757fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +rand = "0.8.5" rs48_lib = "1.3.1" termion = "2.0.1" tokio = { version = "1.21.2", features = ["full"] } diff --git a/src/main.rs b/src/main.rs index 7c6b7cc..43990d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,9 +43,17 @@ async fn game(mut write: OwnedWriteHalf, config: Config) { let rules = GameRules::default(); let mut game = Game::new(rules); let mut controller = SimulatedController::new(50, 20); + let color_seed: u16 = rand::random(); '_game: loop { - let result = turn(&mut game, &mut controller, &mut write, config.delay).await; + let result = turn( + &mut game, + &mut controller, + &mut write, + config.delay, + color_seed, + ) + .await; match result { Ok(()) => (), Err(Error::GameEnd) => continue 'session, @@ -60,8 +68,9 @@ async fn turn( controller: &mut SimulatedController, write: &mut OwnedWriteHalf, delay: Duration, + color_seed: u16, ) -> Result<(), Error> { - let displayer = GridDisplayer::new(1234); + let displayer = GridDisplayer::new(color_seed); let display = displayer.display(game.get_board()); let clear = clear::All; let goto = cursor::Goto(1, 1);