summaryrefslogtreecommitdiff
path: root/src/game.rs
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2019-08-06 20:15:39 +0200
committerJustin Worthe <justin@worthe-it.co.za>2019-08-06 20:15:39 +0200
commite8b28dbbcde3d00a9d82637644734b6c7e79b544 (patch)
treef0c52dba5233fa984e00bc38d7a1cf1488490780 /src/game.rs
parent298d67d4fdb36f8fb81ad6d8e817345e3d692558 (diff)
All valid moves list into the game sim
Diffstat (limited to 'src/game.rs')
-rw-r--r--src/game.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/game.rs b/src/game.rs
index 7ab7725..f49f582 100644
--- a/src/game.rs
+++ b/src/game.rs
@@ -434,8 +434,6 @@ impl GameBoard {
}
pub fn simulate_snowballs(&mut self, actions: [Action; 2]) {
- let map_clone: Map = self.map;
-
for player_index in 0..actions.len() {
if let Action::Snowball(p) = actions[player_index] {
if self.map.at(p).is_some() {
@@ -697,6 +695,17 @@ impl GameBoard {
.map(|(dir, _range)| Command::new(Action::Shoot(dir)))
.collect()
}
+
+ // TODO: Include snowball commands
+ pub fn valid_moves(&self, player_index: usize) -> Vec<Command> {
+ self.valid_shoot_commands(player_index)
+ .iter()
+ .chain(self.valid_move_commands(player_index).iter())
+ .chain(self.valid_bomb_commands(player_index).iter())
+ .chain([Command::new(Action::DoNothing)].iter())
+ .cloned()
+ .collect()
+ }
}
#[cfg(test)]