Commands a robot to attack a unit, dealing the robot's standard amount of damage. Healers cannot attack, and should use `heal()` instead. NoSuchUnit - the unit does not exist (inside the vision range). TeamNotAllowed - the unit is not on the current player's team. InappropriateUnitType - the unit is not a robot, or is a healer. UnitNotOnMap - the unit or target is not on the map. OutOfRange - th
(&mut self, robot_id: UnitID, target_id: UnitID)
| 1134 | /// * OutOfRange - the target location is not in range. |
| 1135 | /// * Overheated - the unit is not ready to attack. |
| 1136 | pub fn attack(&mut self, robot_id: UnitID, target_id: UnitID) -> Result<(), GameError> { |
| 1137 | self.ok_if_can_attack(robot_id, target_id)?; |
| 1138 | self.ok_if_attack_ready(robot_id)?; |
| 1139 | let damage = self.my_unit_mut(robot_id).unwrap().use_attack(); |
| 1140 | if self.my_unit(robot_id).unwrap().unit_type() == UnitType::Mage { |
| 1141 | let epicenter = self.unit(target_id).unwrap().location().map_location().unwrap(); |
| 1142 | for direction in Direction::all().iter() { |
| 1143 | self.damage_location(epicenter.add(*direction), damage); |
| 1144 | } |
| 1145 | } |
| 1146 | self.damage_unit(target_id, damage); |
| 1147 | Ok(()) |
| 1148 | } |
| 1149 | |
| 1150 | // ************************************************************************ |
| 1151 | // ************************* RESEARCH METHODS ***************************** |
no test coverage detected