import java.util.Scanner;

/**
 * Simple, text-based interface for playing "Hunt the Wumpus"
 *   @author Dave Reed
 *   @version 11/15/15
 */
public class HuntTheWumpus {
    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 destroy all of the wumpi (without getting yourself killed).");
        System.out.println("To move to an adjacent cave, enter 'M' and the tunnel number.");
        System.out.println("To toss a grenade into a cave, enter 'T' and the tunnel number.");
        System.out.println();

        Scanner input = new Scanner(System.in);
        while (maze.stillAlive() && maze.stillWumpi()) {
            System.out.println(maze.showLocation());
            System.out.println();
            System.out.print("What do you want to do? ");

            String action = input.next();
            char firstLetter = action.toLowerCase().charAt(0);
            if (firstLetter == 'q') {
                System.out.println("Nobody likes a quitter.\n");
                break;
            }
            else if (firstLetter == 'm' || firstLetter == 't') {
                int target = input.nextInt();
                if (target < 1 || target > 3) {
                    System.out.println("Illegal tunnel number -- please try again.");
                }
                else if (firstLetter == 't') {
                    System.out.println(maze.toss(target));
                } 
                else {
                    System.out.println(maze.move(target));
                }
            }
            else {
                System.out.println("Unrecognized command -- please try again.");
            }
            System.out.println();
        }
        System.out.println("GAME OVER");
    }
}
