Method
kill_invader_at
(&mut self, x: usize, y: usize)
Source from the content-addressed store, hash-verified
| 83 | self.army.iter().any(|invader| invader.y >= NUM_ROWS - 1) |
| 84 | } |
| 85 | pub fn kill_invader_at(&mut self, x: usize, y: usize) -> u16 { |
| 86 | if let Some(idx) = self |
| 87 | .army |
| 88 | .iter() |
| 89 | .position(|invader| (invader.x == x) && (invader.y == y)) |
| 90 | { |
| 91 | let points = self.army[idx].points; |
| 92 | self.army.remove(idx); |
| 93 | points |
| 94 | } else { |
| 95 | 0 |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | impl Default for Invaders { |
Tested by
no test coverage detected