import java.util.Scanner;

/**
 * Simple, text-based interface for playing "Hunt the Wumpus"
 *   @author Dave Reed
 *   @version 11/4/17
 */
public class WumpusTerminal {
    public static void main(String[] args) throws java.io.FileNotFoundException {
        CaveMaze maze = new CaveMaze("caves.txt");

        System.out.println("HUNT THE WUMPUS:  Your mission is to explore the maze of caves");
        System.out.println("and capture all of the wumpi (without getting yourself mauled).");
        System.out.println("To move to an adjacent cave, enter 'M' and the tunnel number.");
        System.out.println("To toss a stun grenade into a cave, enter 'T' and the tunnel number.");

        Scanner input = new Scanner(System.in);
        while (maze.stillAble() && maze.stillWumpi()) {
            System.out.println("\n"+maze.showLocation());

            try {
                String action = input.next();
                if (action.toLowerCase().charAt(0) == 'q') {
                    System.out.println("Nobody likes a quitter.");
                    break;
                }
                if (action.toLowerCase().charAt(0) == 't') {
                    System.out.println(maze.toss(input.nextInt()));
                } else if (action.toLowerCase().charAt(0) == 'm') {
                    System.out.println(maze.move(input.nextInt()));
                } else {
                    System.out.println("Unrecognized command -- please try again.");
                }
            }
            catch (java.util.InputMismatchException e) {
                System.out.println("Unrecognized command -- please try again.");
            }
        }
        System.out.println("\nGAME OVER");
    }
}
