aboutsummaryrefslogtreecommitdiff
path: root/planetwars-matchrunner/src
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-09-17 11:30:52 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-09-17 11:30:52 +0200
commit518ad1d811e87872fcd6d769435f485d0ed31768 (patch)
tree45b7c01259b9167e336a5e9ada939f3300b7684d /planetwars-matchrunner/src
parenta70689faa93961a1e9a8c35d7e5cd90686112173 (diff)
downloadplanetwars.dev-518ad1d811e87872fcd6d769435f485d0ed31768.tar.xz
planetwars.dev-518ad1d811e87872fcd6d769435f485d0ed31768.zip
log initial state
Diffstat (limited to 'planetwars-matchrunner/src')
-rw-r--r--planetwars-matchrunner/src/pw_match.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/planetwars-matchrunner/src/pw_match.rs b/planetwars-matchrunner/src/pw_match.rs
index 56d38d1..03dd37c 100644
--- a/planetwars-matchrunner/src/pw_match.rs
+++ b/planetwars-matchrunner/src/pw_match.rs
@@ -40,6 +40,9 @@ impl PwMatch {
}
pub async fn run(&mut self) {
+ // log initial state
+ self.log_game_state();
+
while !self.match_state.is_finished() {
let player_messages = self.prompt_players().await;
@@ -48,10 +51,7 @@ impl PwMatch {
self.log_player_action(player_id, player_action);
}
self.match_state.step();
-
- // Log state
- let state = self.match_state.serialize_state();
- self.match_ctx.log(MatchLogMessage::GameState(state));
+ self.log_game_state();
}
}
@@ -110,6 +110,11 @@ impl PwMatch {
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) {
match player_action {
PlayerAction::ParseError { data, error } => {