summaryrefslogtreecommitdiff
path: root/src/shooting.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/shooting.rs')
-rw-r--r--src/shooting.rs14
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)
}