/**
 * Player Class.
 * This class is in charge of the Player.
 * This class has a reference to the current room that the player is in.
 * As well, there is a playerHistory variable, in order to undo and redo certain moves.
 * This class implements a doCommand method which will take the input command words and correlate them to actual actions.
 *
 */



public class Player extends Humanoid  {

	private PlayerHistory playerHistory;
	private Room currentRoom;
	private View v;
	
	public Player(int health, Room r, String name){
		super(health, name);
		currentRoom = r;
		playerHistory = new PlayerHistory();
	}
	
	public Player(Room r){
		super();
		currentRoom = r;
		playerHistory = new PlayerHistory();
	}


	public void doCommand(Command c){
		boolean b = false;
		
		if (c.getCommandWord().equals(CommandWords.UNDO)){
			c = playerHistory.undo();
			b = true;
		} else if (c.getCommandWord().equals(CommandWords.REDO)){
			c = playerHistory.redo();
			b = true;
		}
		if(c==null){
			return; //TODO tell view about it
		}
		
		
		if (c.getCommandWord().equals(CommandWords.GO)){
			Direction d = (Direction) c.getSecondWord();
			Room r = currentRoom.getExit(d);
			if(r!=null){
				currentRoom = r;
			} // else error TODO tell view "NO EXIT THERE"
			if(b == false){
				playerHistory.addStep(c);
			}

		} else if (c.getCommandWord().equals(CommandWords.FIGHT)){
			Monster m = currentRoom.getMonster();
			if(m==null){
//				System.out.println("Nothing to Fight!");
				//TODO should probably call the view here..shouldn't be a system.out in this class
				v.monsterMissing();
			} else {
				m.updateHealth(this.getBestItem().getValue());
				this.updateHealth(m.getBestItem().getValue());
				if(m.getHealth()<=0){
					currentRoom.removeMonster(m);
				}
			}
			
		} else if (c.getCommandWord().equals(CommandWords.HELP)){
//	        System.out.println("You are lost. You are alone. You wander around in a cave.\n");
//	        System.out.println("Your command words are:");
//	        System.out.println("GO, PICKUP, DROP, UNDO, REDO, FIGHT, HELP, QUIT\n");
//	        //TODO HELP should be implemented in view class.
			v.displayHelp();
		} else if (c.getCommandWord().equals(CommandWords.PICKUP)){
			Item i = (Item) c.getSecondWord();
			i = currentRoom.getRealItem(i);
			if(currentRoom.hasItem(i)){
				addItem(i);
				currentRoom.removeItem(i);
			}
			if(b == false){
				playerHistory.addStep(c);
			}
		} else if (c.getCommandWord().equals(CommandWords.DROP)){
			Item i = (Item) c.getSecondWord();
			
			if(getInventory().contains(i)){
				
				currentRoom.addItem(i);
				removeItem(i);
			}
			if(b == false){
				playerHistory.addStep(c);
			}
		} else {
			//TODO some sort of extraneous error checking, WORD DOESN'T EXIST
		}//QUIT command does not get passed to the player
		
		
	}
	
	public Room getCurrentRoom(){
		return currentRoom;
	}
	
	public void setView(View v){
		this.v = v;
	}
}

@@ -967,16 +967,19 @@
 ue;%0A%09%09%7D%0A
+%09%09%0A
 %09%09if(c==
@@ -992,41 +992,27 @@
 %0A%09%09%09
-return; //TODO tell view about it
+v.garbageCommand();
 %0A%09%09%7D
@@ -1198,53 +1198,41 @@
 %09%09%09%7D
- //
  else 
-error TODO tell view %22NO EXIT THERE%22
+%7B%0A%09%09%09%09v.invalidRoom();%0A%09%09%09%7D
 %0A%09%09%09
@@ -1405,142 +1405,8 @@
 l)%7B%0A
-//%09%09%09%09System.out.println(%22Nothing to Fight!%22);%0A%09%09%09%09//TODO should probably call the view here..shouldn't be a system.out in this class%0A
 %09%09%09%09
@@ -1679,304 +1679,8 @@
 ))%7B%0A
-//%09        System.out.println(%22You are lost. You are alone. You wander around in a cave.%5Cn%22);%0A//%09        System.out.println(%22Your command words are:%22);%0A//%09        System.out.println(%22GO, PICKUP, DROP, UNDO, REDO, FIGHT, HELP, QUIT%5Cn%22);%0A//%09        //TODO HELP should be implemented in view class.%0A
 %09%09%09v
@@ -2219,139 +2219,12 @@
 %09%09%7D%0A
+
 %09%09%7D 
-else %7B%0A%09%09%09//TODO some sort of extraneous error checking, WORD DOESN'T EXIST%0A%09%09%7D//QUIT command does not get passed to the player
 %0A%09%09%0A

Implement TODO's in conjunction with view methods.