diff options
-rw-r--r-- | src/game.rs | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/game.rs b/src/game.rs index 2a6aebb..dbf02e5 100644 --- a/src/game.rs +++ b/src/game.rs @@ -518,21 +518,25 @@ impl GameBoard { Some(worm.id) }; - 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 { - let target = Point2d::new(x, y); - if (worm.position - target).magnitude_squared() < 36 { - result.push(Command { - worm: select, - action: Action::Bomb(target), - }); + if select.is_none() || self.players[player_index].select_moves > 0 { + 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 { + let target = Point2d::new(x, y); + if (worm.position - target).magnitude_squared() < 36 { + result.push(Command { + worm: select, + action: Action::Bomb(target), + }); + } } } - } - result + result + } else { + Vec::new() + } } None => Vec::new(), } |