import java.util.*;

public class MapGame
{
    // Constants:
    private static final int MAZE_HEIGHT		= 4; // start small to 
    private static final int MAZE_WIDTH			= 4; // simplify debugging
	
    private static final int MAZE_PERCENT_WEAPON= 25;
    private static final int MAZE_PERCENT_MONSTER=25;
	
    private static final int MONSTER_MAX_HP 	= 50;
    private static final int MONSTER_MAX_STR 	= 15;
    private static final int MONSTER_MAX_SKILL 	= 10;
    private static final int MONSTER_MAX_AC 	= 7;

    private static final int WEAPON_MAX_MOD		= 15;

    private static final int WARRIOR_HP 		= 50;
    private static final int WARRIOR_STR 		= 10;
    private static final int WARRIOR_SKILL 		= 15;
    private static final int WARRIOR_AC 		= 5;
    private static final String WARRIOR_NAME 	= "Gnusto Frotz";
    private static final String WARRIOR_TYPE 	= "valiant warrior";
    private static final String WARRIOR_PRONOUN	= "his";
	
    private static final String INTRO = 
	"Welcome to the game.  You control the actions of the valient Gnusto \n"+
	"Frotz, a warrior who has stumbled into a creepy house whose rooms are "+
	"like maze of twisty little passages, all alike. You \n"+
	"can use commands such as 'north' or simply 'n' to move.\n"+
	"You can use 'attack' to attack a monster with a single blow.  You\n"+
	"can also use 'look' to examine the room you are in, and 'get <thing>'\n"+
	"to pick up an item named <thing>. Explore the maze and kill all the "+
	"monsters to win the game!  Or, if you are lame, you can type <quit> \n"+
	"when you are done playing.\n";
	
    private static Room currentRoom;
    
    public static Room getCurrentRoom() { return currentRoom; }
    public static void setCurrentRoom(Room newRoom) { currentRoom = newRoom; }
	
    public static void main(String args[]) 
    {
	// create the player
	Creature player = new Creature(WARRIOR_HP, WARRIOR_STR, WARRIOR_SKILL, 
				       WARRIOR_AC, WARRIOR_NAME, WARRIOR_TYPE, 
				       WARRIOR_PRONOUN);
		
	// create and populate the rooms of the maze
	Map maze = new Map(MAZE_HEIGHT, MAZE_WIDTH);
		
	maze.setMaxMonsterStrength(MONSTER_MAX_STR);
	maze.setMaxMonsterSkill(MONSTER_MAX_SKILL);
	maze.setMaxMonsterHitPoints(MONSTER_MAX_HP);
	maze.setMaxMonsterArmorClass(MONSTER_MAX_AC);
	maze.setMaxWeaponDamageMod(WEAPON_MAX_MOD);
		
	maze.populate(MAZE_PERCENT_WEAPON, MAZE_PERCENT_MONSTER);
	
	// connect all the rooms to their neighbors - use while debugging
	maze.connectAllRooms();
		
	// connect all rooms in a maze - erase the above line and uncomment 
	// the below line when you are ready to start coding and debugging 
	// the maze generation algorithm
	// maze.generateMaze();
		
						
	// place the player and print introduction
	setCurrentRoom(maze.getRoom(0,0));
	System.out.print(INTRO);
		
	Scanner stdin = new Scanner(System.in);
		
	// main loop
	while (maze.allMonstersDead() == false)
	    {
		MapPrinter.printMap(maze,currentRoom);
		Room newRoom = currentRoom.enterRoom(player);
		if (newRoom == null) 
		    {
			System.out.println("Thank you for playing!  Goodbye.");
			return;
		    }
		else
		    {
			setCurrentRoom(newRoom);
		    }
	    }
	System.out.println("All monsters are dead!  You win the game. \n"+
			   "Congratulations and goodbye.");
    }
}
