summaryrefslogtreecommitdiff
path: root/src/game.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.rs')
-rw-r--r--src/game.rs47
1 files changed, 40 insertions, 7 deletions
diff --git a/src/game.rs b/src/game.rs
index b3cfc62..4e07e2f 100644
--- a/src/game.rs
+++ b/src/game.rs
@@ -52,7 +52,9 @@ impl GameBoard {
position: Point2d::new(w.position.x, w.position.y),
weapon_damage: commando_damage,
weapon_range: commando_range,
+ rounds_until_unfrozen: w.rounds_until_unfrozen,
bombs: w.banana_bombs.as_ref().map(|b| b.count).unwrap_or(0),
+ snowballs: w.snowballs.as_ref().map(|b| b.count).unwrap_or(0),
})
.collect(),
};
@@ -71,11 +73,17 @@ impl GameBoard {
position: Point2d::new(w.position.x, w.position.y),
weapon_damage: commando_damage,
weapon_range: commando_range,
+ rounds_until_unfrozen: w.rounds_until_unfrozen,
bombs: if w.profession == json::WormType::Agent {
STARTING_BOMBS
} else {
0
},
+ snowballs: if w.profession == json::WormType::Technologist {
+ STARTING_SNOWBALLS
+ } else {
+ 0
+ },
})
.collect(),
};
@@ -169,20 +177,22 @@ impl GameBoard {
.flat_map(|p| p.worms.iter())
.map(|w| w.position)
.collect();
+
+ // TODO: Do some asssertions about the state of lava
}
pub fn simulate(&mut self, moves: [Command; 2]) {
- let actions = [moves[0].action, moves[1].action];
-
- // TODO: move lava in
- // TODO: hurt worms that are standing on lava
- // TODO: tick frozen timers
-
+ self.simulate_worms_on_lava();
+ self.simulate_tick_frozen_timers();
self.simulate_select(moves);
+
+ let actions = self.identify_actions(moves);
+ // TODO: Simulate frozen worms (nullify their actions)
self.simulate_moves(actions);
self.simulate_digs(actions);
self.simulate_bombs(actions);
- // TODO: simulalte snowballs (question order on forums?)
+ // TODO: Question order of actions on the forums
+ self.simulate_snowballs(actions);
self.simulate_shoots(actions);
for player in &mut self.players {
@@ -205,6 +215,25 @@ impl GameBoard {
};
}
+ fn simulate_worms_on_lava(&mut self) {
+ // TODO
+ }
+
+ fn simulate_tick_frozen_timers(&mut self) {
+ // TODO
+ }
+
+ fn identify_actions(&self, moves: [Command; 2]) -> [Action; 2] {
+ let mut it = self.players.iter().zip(moves.iter()).map(|(p, m)| {
+ if p.active_worm_is_frozen() {
+ Action::DoNothing
+ } else {
+ m.action
+ }
+ });
+ [it.next().unwrap(), it.next().unwrap()]
+ }
+
fn simulate_select(&mut self, moves: [Command; 2]) {
moves
.iter()
@@ -368,6 +397,10 @@ impl GameBoard {
}
}
+ pub fn simulate_snowballs(&mut self, actions: [Action; 2]) {
+ // TODO: simulalte snowballs
+ }
+
fn simulate_shoots(&mut self, actions: [Action; 2]) {
'players_loop: for player_index in 0..actions.len() {
if let Action::Shoot(dir) = actions[player_index] {