Moves the robot in the given direction. NoSuchUnit - the robot does not exist (within the vision range). TeamNotAllowed - the robot is not on the current player's team. UnitNotOnMap - the robot is not on the map. LocationNotVisible - the location is outside the vision range. LocationOffMap - the location is off the map. LocationNotEmpty - the location is occupied by a unit or terrain. Overheated
(&mut self, robot_id: UnitID, direction: Direction)
| 1035 | /// * LocationNotEmpty - the location is occupied by a unit or terrain. |
| 1036 | /// * Overheated - the robot is not ready to move again. |
| 1037 | pub fn move_robot(&mut self, robot_id: UnitID, direction: Direction) -> Result<(), GameError> { |
| 1038 | self.ok_if_can_move(robot_id, direction)?; |
| 1039 | self.ok_if_move_ready(robot_id)?; |
| 1040 | let dest = match self.my_unit(robot_id).unwrap().location() { |
| 1041 | OnMap(loc) => loc.add(direction), |
| 1042 | _ => unreachable!(), |
| 1043 | }; |
| 1044 | self.move_to(robot_id, dest); |
| 1045 | Ok(()) |
| 1046 | } |
| 1047 | |
| 1048 | fn move_to(&mut self, robot_id: UnitID, location: MapLocation) { |
| 1049 | self.remove_unit(robot_id); |