From 7d3124030f2518ab5ed6988d941a952d9f514708 Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Sun, 31 Mar 2024 15:39:02 +0200 Subject: [PATCH] check turn stage before rolling dice --- client_cli/src/app.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/client_cli/src/app.rs b/client_cli/src/app.rs index 97ba41b..0ac3c5d 100644 --- a/client_cli/src/app.rs +++ b/client_cli/src/app.rs @@ -1,9 +1,6 @@ use bot::Bot; use pretty_assertions::assert_eq; -use std::fmt; -use store::{ - CheckerMove, Color, Dice, DiceRoller, GameEvent, GameState, PlayerId, Stage, TurnStage, -}; +use store::{CheckerMove, DiceRoller, GameEvent, GameState, PlayerId, Stage, TurnStage}; #[derive(Debug, Default)] pub struct AppArgs { @@ -90,8 +87,6 @@ impl App { } } - fn get_my_player(&mut self) {} - pub fn start(&mut self) { self.game.state = GameState::new(); } @@ -128,6 +123,10 @@ impl App { println!("player_id not set "); return; } + if self.game.state.turn_stage != TurnStage::RollDice { + println!("Not in the dice roll stage"); + return; + } let dice = self.game.dice_roller.roll(); self.game.handle_event(&GameEvent::RollResult { player_id: self.game.player_id.unwrap(),