From 0916919b673fa07c7ac385e05fe9a58e8baf925e Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Thu, 12 Dec 2024 15:28:33 -0600 Subject: put game loop in its own function Signed-off-by: Matt Strapp --- wwb/src/main.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wwb/src/main.rs b/wwb/src/main.rs index 97f27cc..08f0aba 100644 --- a/wwb/src/main.rs +++ b/wwb/src/main.rs @@ -27,6 +27,10 @@ fn main() { .target(Target::Stdout) .init(); + game_loop(); +} + +fn game_loop() { let game = Arc::new(Mutex::new(Game::default())); // Set up Ctrl-C handler to print the game state before exiting. @@ -73,7 +77,8 @@ fn main() { if current_space == BOARD_SIZE + 1 { log::error!( "Player {} has reached the Finish space and won on turn {}!", - current_player_number, game.turn_count + current_player_number, + game.turn_count ); break; } @@ -100,10 +105,7 @@ fn main() { for player in game.players.iter_mut() { if player.current_space == current_space && player.current_space != 0 { - log::debug!( - "Two players collided on space {}!", - current_space - ); + log::debug!("Two players collided on space {}!", current_space); player.current_space = 0; current_space = 0; collision = true; -- cgit v1.2.3