log initial state

This commit is contained in:
Ilion Beyst 2022-09-17 11:30:52 +02:00
parent a70689faa9
commit 518ad1d811

View file

@ -40,6 +40,9 @@ impl PwMatch {
} }
pub async fn run(&mut self) { pub async fn run(&mut self) {
// log initial state
self.log_game_state();
while !self.match_state.is_finished() { while !self.match_state.is_finished() {
let player_messages = self.prompt_players().await; let player_messages = self.prompt_players().await;
@ -48,10 +51,7 @@ impl PwMatch {
self.log_player_action(player_id, player_action); self.log_player_action(player_id, player_action);
} }
self.match_state.step(); self.match_state.step();
self.log_game_state();
// Log state
let state = self.match_state.serialize_state();
self.match_ctx.log(MatchLogMessage::GameState(state));
} }
} }
@ -110,6 +110,11 @@ impl PwMatch {
PlayerAction::Commands(commands) PlayerAction::Commands(commands)
} }
fn log_game_state(&mut self) {
let state = self.match_state.serialize_state();
self.match_ctx.log(MatchLogMessage::GameState(state));
}
fn log_player_action(&mut self, player_id: usize, player_action: PlayerAction) { fn log_player_action(&mut self, player_id: usize, player_action: PlayerAction) {
match player_action { match player_action {
PlayerAction::ParseError { data, error } => { PlayerAction::ParseError { data, error } => {