diff options
Diffstat (limited to 'src/game.rs')
-rw-r--r-- | src/game.rs | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/game.rs b/src/game.rs index f5bcfa2..56c583b 100644 --- a/src/game.rs +++ b/src/game.rs @@ -15,7 +15,6 @@ use map::*; use arrayvec::ArrayVec; use fnv::FnvHashSet; -// TODO: How much sense does it actually make to split the worms between the players? #[derive(Debug, PartialEq, Eq, Clone)] pub struct GameBoard { pub round: u16, @@ -72,7 +71,11 @@ impl GameBoard { position: Point2d::new(w.position.x, w.position.y), weapon_damage: commando_damage, weapon_range: commando_range, - bombs: if w.health == 100 { 3 } else { 0 }, // TODO: parse and check worm type rather, move these out to constants + bombs: if w.profession == json::WormType::Agent { + STARTING_BOMBS + } else { + 0 + }, }) .collect(), }; @@ -126,7 +129,17 @@ impl GameBoard { if let Some(worm) = self.players[1].find_worm_mut(w.id) { worm.health = w.health; worm.position = Point2d::new(w.position.x, w.position.y); - // TODO: How to update opponent worm bombs? + // TODO: How to update opponent worm bombs? One idea: + // start the update by passing in the move that I did, + // and doing a simulation where the opponent did + // nothing. Then, looking at the points that the + // opponent actually got, determine if they did a + // simple walk / dig / shoot or if they hit multiple + // worms, hit worms with bomb levels of damage, or + // destroyed a dirt not next to them. I can further + // tell if they used a select (number of selects), and + // who their new active worm is, and if that worm + // could have bombed. } } self.players[0].moves_score = json.my_player.score - json.my_player.health_score(); @@ -218,8 +231,7 @@ impl GameBoard { fn simulate_moves(&mut self, actions: [Action; 2]) { match actions { [Action::Move(p1), Action::Move(p2)] if p1.x == p2.x && p1.y == p2.y => { - // TODO: Get this from some sort of config rather - let damage = 20; + let damage = COLLISSION_DAMAGE; debug_assert_eq!( Some(false), @@ -308,6 +320,7 @@ impl GameBoard { // TODO: Destroy health packs + // TODO: iter, filter_map, filter, filter_map... flatten this block down a smidge. for player_index in 0..actions.len() { if let Action::Bomb(p) = actions[player_index] { if self.map.at(p).is_some() { @@ -317,15 +330,12 @@ impl GameBoard { worm.bombs = worm.bombs.saturating_sub(1); - // damage as per https://forum.entelect.co.za/uploads/default/original/2X/8/89e6e6cf35791a0448b5a6bbeb63c558ce41804a.jpeg - for &(damage_offset, weapon_damage) in BOMB_DAMAGES.iter() { let target = p + damage_offset; if self.map.at(target) == Some(true) { self.map.clear(target); - // TODO: How does this score get assigned if both players lobbed a banana? - // (answer, currently all to A, but watch https://forum.entelect.co.za/t/scoring-with-simultaneous-banana-digs/766/1 + // TODO: Fix this so that simultaneous bomb throwing gives points to both players self.players[player_index].moves_score += DIG_SCORE; } @@ -566,13 +576,15 @@ impl GameBoard { } }) .filter(|(dir, range)| { - // TODO if this filtered all players, I don't need to dedup let diff = dir.as_vec(); + // NB: This is up to range EXCLUSIVE, so if there's + // anything in the way, even another good shot, skip. !(1..*range).any(|distance| { self.map.at(center + diff * distance) != Some(false) - && !self.players[player_index] - .worms + && !self + .players .iter() + .flat_map(|p| p.worms.iter()) .any(|w| w.position == center + diff * distance) }) }) |