diff options
Diffstat (limited to 'src/game.rs')
-rw-r--r-- | src/game.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/game.rs b/src/game.rs index e3fb5c0..fe54f40 100644 --- a/src/game.rs +++ b/src/game.rs @@ -80,7 +80,7 @@ impl GameBoard { } pub fn update(&mut self, json: json::State) { - for w in json.my_player.worms { + for w in &json.my_player.worms { if let Some(worm) = self.players[0].find_worm_mut(w.id) { worm.health = w.health; worm.position = Point2d::new(w.position.x, w.position.y); @@ -105,15 +105,15 @@ impl GameBoard { self.map.clear(Point2d::new(cell.x, cell.y)) } } - - self.round += 1; - debug_assert_eq!(json.current_round, self.round); - - // Remove dead worms and update active worm + for player in &mut self.players { player.clear_dead_worms(); player.next_active_worm(); } + debug_assert_eq!(json.active_worm_index().unwrap(), self.players[0].active_worm); + + self.round += 1; + debug_assert_eq!(json.current_round, self.round); } pub fn simulate(&mut self, moves: [Command; 2]) { |