diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2019-06-28 21:20:37 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2019-06-28 21:20:37 +0200 |
commit | a07cbfd67849b98a881f930e12e07c429e604ac4 (patch) | |
tree | 4b4ad859c169d6366ca2e6e91d0ef09e5986396f /src/game.rs | |
parent | e20e7f0a9029d33c67869951371cc03965127b31 (diff) |
updated active worm in update
This might change weirdly because of the select move.
Diffstat (limited to 'src/game.rs')
-rw-r--r-- | src/game.rs | 14 |
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(), |