diff options
Diffstat (limited to 'src/shooting.rs')
-rw-r--r-- | src/shooting.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/shooting.rs b/src/shooting.rs index 14f2b81..c2ca56e 100644 --- a/src/shooting.rs +++ b/src/shooting.rs @@ -1,6 +1,16 @@ use actions::*; use math::*; +use state::*; -pub fn shoot_randomly(map_size: u16) -> Action { - Action::Shoot(Point::random(map_size)) +pub fn shoot_randomly(state: &State) -> Action { + let mut shot: Point; + + while { + shot = Point::random(state.map_size); + let ref target = state.opponent_map.cells[shot.x as usize][shot.y as usize]; + target.damaged || target.missed + } {} + + + Action::Shoot(shot) } |