// 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;
	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. Assumes that the roomstates have been built already.
	public Room(Element eRoom)
	{
		return;
	}
	
	
	// 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;
	}
}
@@ -400,16 +400,122 @@
 states;%0A
+%09KeyCombo%5B%5D _roomkeys;%09%09// Room-global keys! In case you want to do something regardless of the roomstate%0A
 %09int _ro
@@ -973,102 +973,554 @@
 tor.
- Assumes that the roomstates have been built already.%0A%09public Room(Element eRoom)%0A%09%7B%0A%09%09return;
+%0A%09public Room(Node roomNode)%0A%09%7B%0A%09%09NodeList roomkeys = ((Element)roomNode).getElementsByTagName(%22roomkey%22);%0A%09%09%0A%09%09this._roomkeys = new KeyCombo%5Broomkeys.getLength()%5D;%0A%09%09%0A%09%09for(int i = 0; i %3C roomkeys.getLength(); i++)%0A%09%09%7B%0A%09%09%09this._roomkeys%5Bi%5D = new KeyCombo(roomkeys.item(i));%0A%09%09%7D%0A%09%09%0A%09%09%0A%09%09NodeList roomstates = ((Element)roomNode).getElementsByTagName(%22roomstate%22);%0A%09%09%0A%09%09this._roomstates = new Roomstate%5Broomstates.getLength()%5D;%0A%09%09%0A%09%09for(int i = 0;i %3C roomstates.getLength(); i++)%0A%09%09%7B%0A%09%09%09this._roomstates%5Bi%5D = new Roomstate(roomstates.item(i));%0A%09%09%7D
 %0A%09%7D%0A

Add Room(Node) constructor