class Main {
  private static final Game[] GAMES = {new Maze()};

  public static void main(String[] args) {
    while (true) {
      System.out.println("\nWelcome to the ASCII game menu.");
      for (int index = 0; index < GAMES.length; index++) {
        System.out.printf(
            "%d. %s%n   %s%n",
            index + 1,
            GAMES[index].name,
            GAMES[index].description);
      }

      System.out.printf("Choose 1-%d, or Q to quit: ", GAMES.length);
      String choice = Game.INPUT.nextLine().trim();

      if (choice.equalsIgnoreCase("q")) {
        System.out.println("Thanks for playing.");
        return;
      }

      try {
        int gameIndex = Integer.parseInt(choice) - 1;
        if (gameIndex >= 0 && gameIndex < GAMES.length) {
          GAMES[gameIndex].play();
        } else {
          System.out.println("That game number is not available.");
        }
      } catch (NumberFormatException exception) {
        System.out.println("Please enter a game number or Q.");
      }
    }
  }
}