def drive_rovers(self):
        print("")
        print(
            "Which rover would you like to give orders to? (choose a number)")
        MissionComms.print_bold("----------------------------------")
        MissionComms.print_bold(f"Nr \t| Name  \t| Position")
        MissionComms.print_bold("----------------------------------")
        for index, rover in enumerate(self.rovers):
            MissionComms.print_bold(
                f"{index} \t| {rover.name}  \t| {rover.get_rover_position()}")

        while True:
            try:
                index = int(input())
                if 0 <= index < len(self.rovers):
                    break
            except ValueError:
                pass

            MissionComms.print_warn(
                f"Please provide a valid number between 0 and {len(self.rovers) - 1}"
            )

        rover = self.rovers[index]
        commands = input(f"\nPlease enter commands for {rover.name}:\n")
        self._manage_rover(rover, commands)
    def deploy_rover(self):
        prompt = "\nWhere should the rover be deployed?\n" if len(self.rovers) == 0 \
            else "\nWhere should the next rover be deployed?\n"
        while True:
            try:
                coordinates = input(prompt).split()
                x = int(coordinates[0])
                y = int(coordinates[1])
                d = coordinates[2].upper()
                if d not in ['N', 'S', 'E', 'W']:
                    MissionComms.print_warn(
                        f"Not a valid direction, options are N, S, E, and W")
                    continue
                if x > self.max_x or y > self.max_y:
                    MissionComms.print_warn(
                        f"Not a valid position, try and keep it in bounds")
                    continue
                rover = Rover("Rover", x, y, d)
                self.collision_avoidance(rover, deployment=True)
                break
            except (ValueError, IndexError):
                MissionComms.print_warn(
                    f"Expecting 2 numbers and a direction in the format: 0 0 N"
                )
                continue
            except RoverError:
                MissionComms.print_warn(
                    f"A rover is already deployed there, try again.")
                continue

        MissionComms.print_info(
            f"{rover.name} deployed at position:\t {rover.get_rover_position()}"
        )
        self.rovers.append(rover)
        self._drive_rover(rover)
 def _action_command(self, command: str, rover: Rover) -> None:
     command = command.upper()
     if command == 'L':
         rover.rotate_left()
     elif command == 'R':
         rover.rotate_right()
     elif command == 'M':
         try:
             self.collision_avoidance(rover)
             rover.move_forward()
         except RoverError:
             raise CommandAbort("Aborting commands")
     else:
         MissionComms.print_warn(
             f"{command} is not a valid command, ignoring this command.")
 def scout_plateau(self):
     while True:
         size = input(f"\nHow big is the plateau?\nFor example: `5 5`\n")
         max_coordinates = size.split()
         try:
             self.max_x = int(max_coordinates[0])
             self.max_y = int(max_coordinates[1])
             if self.max_x == 0 or self.max_y == 0:
                 MissionComms.print_warn(
                     "We can do better than that, make the plateau bigger than 0"
                 )
                 continue
             MissionComms.print_info(
                 f"Plateau confirmed to be {self.max_x}x{self.max_y}")
             break
         except (IndexError, ValueError):
             MissionComms.print_warn(
                 "Expecting 2 coordinates separated by a space, for example: 5 5"
             )
             continue
    def __init__(self, message):
        MissionComms.print_warn(message)

        super().__init__(message)
    print("Mission options: (choose a number)")
    MissionComms.print_bold("----------------------------------")
    MissionComms.print_bold(f"Nr \t| Level \t| Description")
    MissionComms.print_bold("----------------------------------")
    MissionComms.print_bold(
        f"0 \t| Beginner \t| Deploy one rover at a time (The assignment use case)"
    )
    MissionComms.print_bold(
        f"1 \t| Advanced \t| Deploy multiple rovers at once (I got carried away...)"
    )

    while True:
        try:
            l = input()
            level = int(l)
            if 0 <= level < 2:
                break
        except ValueError:
            pass

        MissionComms.print_warn("Expecting a number, 0 or 1")
        continue

    if level is 0:
        beginner()
    elif level is 1:
        advanced()

    MissionComms.print_pass("Thank you for playing :)")