Lands the rocket, damaging the units in adjacent squares. The rocket is destroyed if it lands on a factory, rocket, or impassable terrain. Also resets the amount of karbonite at that location if the rocket successfully lands.
(&mut self, rocket_id: UnitID, destination: MapLocation)
| 1987 | /// Also resets the amount of karbonite at that location if the rocket |
| 1988 | /// successfully lands. |
| 1989 | fn land_rocket(&mut self, rocket_id: UnitID, destination: MapLocation) { |
| 1990 | let blast_damage = self.my_unit(rocket_id).unwrap().rocket_blast_damage().unwrap(); |
| 1991 | if self.my_planet().units_by_loc.contains_key(&destination) { |
| 1992 | let victim_id = *self.my_planet().units_by_loc.get(&destination).unwrap(); |
| 1993 | let should_destroy_rocket = match self.unit(victim_id).unwrap().unit_type() { |
| 1994 | UnitType::Rocket => true, |
| 1995 | UnitType::Factory => true, |
| 1996 | _ => false, |
| 1997 | }; |
| 1998 | self.destroy_unit(victim_id); |
| 1999 | if should_destroy_rocket { |
| 2000 | self.destroy_unit(rocket_id); |
| 2001 | } else { |
| 2002 | self.my_unit_mut(rocket_id).unwrap().land_rocket(destination); |
| 2003 | self.move_from_space(rocket_id); |
| 2004 | self.my_planet_mut().karbonite[destination.y as usize][destination.x as usize] = 0; |
| 2005 | } |
| 2006 | |
| 2007 | } else { |
| 2008 | self.my_unit_mut(rocket_id).unwrap().land_rocket(destination); |
| 2009 | self.move_from_space(rocket_id); |
| 2010 | self.my_planet_mut().karbonite[destination.y as usize][destination.x as usize] = 0; |
| 2011 | } |
| 2012 | |
| 2013 | for dir in Direction::all() { |
| 2014 | self.damage_location(destination.add(dir), blast_damage); |
| 2015 | } |
| 2016 | } |
| 2017 | |
| 2018 | fn process_rockets(&mut self, team: Team) { |
| 2019 | let landings = self.get_team(team).rocket_landings.landings_on(self.round); |