diff --git a/store/src/cxxengine.rs b/store/src/cxxengine.rs index a866e15..3758e2a 100644 --- a/store/src/cxxengine.rs +++ b/store/src/cxxengine.rs @@ -98,7 +98,9 @@ pub fn new_trictrac_engine() -> Box { let mut game_state = GameState::new(false); // schools_enabled = false game_state.init_player("player1"); game_state.init_player("player2"); - game_state.consume(&GameEvent::BeginGame { goes_first: 1 }); + game_state + .consume(&GameEvent::BeginGame { goes_first: 1 }) + .expect("BeginGame failed during engine initialization"); Box::new(TricTracEngine { game_state }) } @@ -189,7 +191,8 @@ impl TricTracEngine { values: (dice.die1, dice.die2), }; self.game_state - .consume(&GameEvent::RollResult { player_id, dice }); + .consume(&GameEvent::RollResult { player_id, dice }) + .map_err(|e| anyhow::anyhow!(e))?; Ok(()) } @@ -208,7 +211,9 @@ impl TricTracEngine { match event { Some(evt) if self.game_state.validate(&evt) => { - self.game_state.consume(&evt); + self.game_state + .consume(&evt) + .map_err(|e| anyhow::anyhow!(e))?; Ok(()) } Some(evt) => anyhow::bail!(