summaryrefslogtreecommitdiff
path: root/src/game.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.rs')
-rw-r--r--src/game.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/game.rs b/src/game.rs
index 7c6b649..e3caf4e 100644
--- a/src/game.rs
+++ b/src/game.rs
@@ -129,7 +129,6 @@ impl GameBoard {
// TODO: How to update opponent worm bombs?
}
}
-
self.players[0].moves_score = json.my_player.score - json.my_player.health_score();
self.players[1].moves_score = json.opponents[0].score - json.opponents[0].health_score();
@@ -156,12 +155,9 @@ impl GameBoard {
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.players[0].active_worm = json.active_worm_index().unwrap_or(0);
+ self.players[1].active_worm = json.opponent_active_worm_index().unwrap_or(0);
self.round += 1;
debug_assert_eq!(json.current_round, self.round);
@@ -508,7 +504,7 @@ impl GameBoard {
Some(worm.id)
};
- let mut result = Vec::with_capacity(11*11-12);
+ let mut result = Vec::with_capacity(11 * 11 - 12);
for y in worm.position.y - 5..=worm.position.y + 5 {
for x in worm.position.x - 5..=worm.position.x + 5 {
@@ -516,12 +512,12 @@ impl GameBoard {
if (worm.position - target).magnitude_squared() < 36 {
result.push(Command {
worm: select,
- action: Action::Bomb(target)
+ action: Action::Bomb(target),
});
}
}
}
-
+
result
}
None => Vec::new(),