// Author: Ian McDevitt
// Title: The Utopian Engine
// Purpose: Text Adventure Game Engine

// This class represents a room, and contains all pertinent data. See variable declaration for explanation of variable usage.

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Room
{
	boolean _can_travel = true;
	Roomstate[] _roomstates;
	KeyCombo[] _roomkeys;		// Room-global keys! In case you want to do something regardless of the roomstate
	int _roomstate = 0;			// roomstate is the state of the room. Rooms may have anywhere from 1 to 2147483647 roomstates.
								// Each roomstate basically functions as its own room, but only one can exist at a time
								// and they will all always occupy the same space in the two-dimensional grid of rooms

	// Default constructor. _can_travel keeps the player from entering the Room.
	public Room()		
	{
		this._can_travel = false;
	}
	
	// Main constructor.
	public Room(Node roomNode)
	{
		NodeList roomkeys = ((Element)roomNode).getElementsByTagName("roomkey");
		
		this._roomkeys = new KeyCombo[roomkeys.getLength()];
		
		for(int i = 0; i < roomkeys.getLength(); i++)
		{
			this._roomkeys[i] = new KeyCombo(roomkeys.item(i));
		}
		
		
		NodeList roomstates = ((Element)roomNode).getElementsByTagName("roomstate");
		
		this._roomstates = new Roomstate[roomstates.getLength()];
		
		for(int i = 0;i < roomstates.getLength(); i++)
		{
			this._roomstates[i] = new Roomstate(roomstates.item(i));
		}
	}
	
	
	// Gets the current roomstate of the current room
	public int getRoomstate()
	{
		return this._roomstate;
	}

	public void checkKeys(String in)
	{
		// Make this do things. This essentially will ask the Roomstate if it has the key.
	}
	
	// Returns the long description if it has not been seen, or the short description otherwise
	public String description()
	{
		return this._roomstates[this._roomstate].description();
	}
	
	// Returns the long description; this function is used whenever the player inputs the "look" (or similar) command
	public String description(boolean check)
	{
		return this._roomstates[this._roomstate].description(check);
	}

	// Updates roomstate based on roomstatefactor
	public void changeRoomstate(int roomstatefactor)
	{
		this._roomstate += roomstatefactor;
	}
	
	// Sets roomstate to the new roomstate. As of yet, this function is unused
	public void setRoomstate(int newRoomstate)
	{
		this._roomstate = newRoomstate;
	}
	
	public boolean canTravel()
	{
		return this._can_travel;
	}
}
@@ -1680,60 +1680,78 @@
 %09// 
-Make this do things. This essentially will as
+TODO: Check _roomkeys for a match%0A%09%09// TODO: Failing that, chec
 k the 
-R
+r
 ooms
@@ -1759,334 +1759,145 @@
 ate 
-if it has the key.%0A%09%7D%0A%09%0A%09// Returns the long description if it has not been seen, or the short description otherwise%0A%09public String description()%0A%09%7B%0A%09%09return this._roomstates%5Bthis._roomstate%5D.description();%0A%09%7D%0A%09%0A%09// Returns the long description; this function is used whenever the player inputs the %22look%22 (or similar) command
+for a match.%0A%09%09// TODO: Failing that, return generic failure message.%0A%09%7D%0A%09%0A%09// Passthrough to the Roomstate class's description function.
 %0A%09pu
@@ -1928,21 +1928,24 @@
 boolean 
-check
+longDesc
 )%0A%09%7B%0A%09%09r
@@ -1996,21 +1996,24 @@
 ription(
-check
+longDesc
 );%0A%09%7D%0A%0A%09

Make description pass through to roomstate