mstar
Class Room

java.lang.Object
  |
  +--mstar.Room

public class Room
extends java.lang.Object
implements java.io.Serializable

A class that represents a room in the collaborative environment and information about that room including: name, description, database reference, commands, obvious exits, possible and fallback exits, contents and chatter. In addition there are methods for creating psuedo-MAAS-Neotek representations of the room that can be written to map files on disk, and methods for adding contents and exits.

Version:
1.6
Author:
Thaddeus O. Cooper
See Also:
Serialized Form

Constructor Summary
Room()
          This object represents a room in the Mud/MOO.
Room(java.lang.String name)
          This object represents a room in the Mud/MOO.
 
Method Summary
 void addBadExit(Exit e)
          This routine adds an exit to the bad exit list.
 void addContents(java.lang.String c)
          This routine adds contents to the list of contents for this room.
 void addGoodExit(Exit e)
          This routine adds an exit to the good exit list.
 void addSuspectExit(Exit e)
           
 void clearVisitedExits()
          Deprecated.  
 boolean containsObject(java.lang.String object)
          This routine determines if an object is contained in this room.
 boolean equals(Room r)
          This routine determines if the room r is the same as this room.
 boolean exitExists(int e)
          This routine determines if this room has an exit that points to a specific room.
 Exit[] getBadExits()
          This routine returns the bad exits that are currently known for this room.
 java.lang.String[] getChatter()
          This routine returns an array of stored chatter for this room.
 java.lang.String[] getCommands()
          This routine returns the shown commands for this room.
 java.lang.String[] getContents()
          This routine returns a list of contents that were seen in this room.
 java.lang.String getDBReference()
          This routine gets the database reference for this room.
 java.lang.String getDescription()
          This routine gets the description for this room.
 Exit getExit(int e)
          This routine returns an exit that points to a specific room.
 java.lang.String[] getFallbackExits()
          This routine returns the list of fallback exits.
 java.util.GregorianCalendar getFirstIn()
          This routine gets the time that this room was first entered.
 Exit[] getGoodExits()
          This routine returns the good exits that are currently known for this room.
 int getId()
          This routine gets the numeric identifier for this room.
 java.util.GregorianCalendar getLastIn()
          This routine gets the last time that this room was entered.
 java.lang.String getName()
          This routine gets the name of this room.
 java.lang.String getNextUnexploredExit()
          This routine returns the next unexplored exit for this room if one exits.
 Exit getNextUnvisitedExit()
          Deprecated.  
 java.lang.String[] getPossibleExits()
          This routine returns the possible exits for this room.
 java.lang.String[] getShownExits()
          This routine returns the shown exits for this room.
 Exit[] getSuspectExits()
          This routine returns the suspect exits that are currently known for this room.
 long getTotalTimeIn()
          This routine gets the total time in this room.
 boolean getUseFallbackExits()
          This routine returns whether or not fallback exits should be used in finding exits in the room.
 boolean getUsePossibleExits()
          This routine returns whether or not possible exits should be used in finding exits in the room.
 boolean getVisited()
          Deprecated.  
 boolean hasConfusingPathTo()
          This routine returns whether the path to this room is confusing.
 boolean hasUnexploredExits()
          This routine determines if this room has any unexplored exits.
 boolean hasUnvisitedExits()
          Deprecated.  
 void moveGoodExitToSuspectExit(Exit e)
           
 void removeBadExit(Exit e)
          This routine removes an exit from the bad exits list.
 void removeGoodExit(Exit e)
          This routine removes an exit from the good exits list.
 void setChatter(java.util.Vector v)
          This routine sets the chatter vector.
 void setCommands(java.lang.String[] commands)
          This routine sets the shown commands for this room.
 void setConfusingPathTo(boolean confusingPathTo)
          This routine sets whether this room has a confusing path to it.
 void setDBReference(java.lang.String dbReference)
          This routine sets the database reference for this room.
 void setDescription(java.lang.String description)
          This routine sets the description for this room.
 void setFallbackExits(java.lang.String[] fallbackExits)
          This routine sets the fallback exits.
 void setFirstIn(java.util.GregorianCalendar firstIn)
          This routine sets the time that this room was first entered.
 void setId(int id)
          This routine sets the numeric identifier for this room.
 void setLastIn(java.util.GregorianCalendar lastIn)
          This routine sets the last time that this room was entered.
 void setName(java.lang.String name)
          This routine sets the name of this room.
 void setPossibleExits(java.lang.String[] possibleExits)
          This routine sets the possible exits for this room.
 void setShownExits(java.lang.String[] shownExits)
          This routine sets the shown exits for this room.
 void setTotalTimeIn(long totalTimeIn)
          This routine sets the total time in this room.
 void setUseFallbackExits(boolean useFallbackExits)
          This routine sets whether or not fallback exits are used in finding exits in the room.
 void setUsePossibleExits(boolean usePossibleExits)
          This routine sets whether or not possible exits are used in finding exits in the room.
 void setVisited(boolean visited)
          Deprecated.  
 java.lang.String shownExitsToString()
          This routine returns the shown exits for this room as a string.
 java.lang.String toMap()
          This routine returns the String that represents this room as a Mass NEOTEK room object.
 java.lang.String toString()
          This routine returns the String representation for this room.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Room

public Room()
This object represents a room in the Mud/MOO. It contains a name at a minimum, and information about the description, exits, contents, and other related data.

Room

public Room(java.lang.String name)
This object represents a room in the Mud/MOO. It contains a name at a minimum, and information about the description, exits, contents, and other related data.
Parameters:
name - the name of this room.
Method Detail

setId

public void setId(int id)
This routine sets the numeric identifier for this room. This identifier is used to uniquely identify this room from other similar rooms.
Parameters:
id - the numeric identifier for this room.

getId

public int getId()
This routine gets the numeric identifier for this room. This identifier is used to uniquely identify this room from other similar rooms.
Returns:
id the numeric identifier for this room.

setName

public void setName(java.lang.String name)
This routine sets the name of this room.
Parameters:
name - the name of this room. This is generally derived from the room description returned by the Mud/MOO.

getName

public java.lang.String getName()
This routine gets the name of this room.
Returns:
name the name of this room.

setDBReference

public void setDBReference(java.lang.String dbReference)
This routine sets the database reference for this room. The database reference is sometimes available from the description that the Mud/MOO returns.
Parameters:
dbReference - the database reference for this room.

getDBReference

public java.lang.String getDBReference()
This routine gets the database reference for this room.
Returns:
dbReference the database reference for this room.

setDescription

public void setDescription(java.lang.String description)
This routine sets the description for this room. The description, when available, is returned from the description that the Mud/MOO returns.
Parameters:
description - the description of this room.

getDescription

public java.lang.String getDescription()
This routine gets the description for this room.
Returns:
description the description of this room or null if none exists.

setChatter

public void setChatter(java.util.Vector v)
This routine sets the chatter vector. The chatter vector stores "chatter" that was heard in the room while waiting for expected output. Chatter is defined as any text that the Mud/MOO generated that was not attributed to a command that the robot executed.
Parameters:
v - the chatter vector to be associated with this room.

getChatter

public java.lang.String[] getChatter()
This routine returns an array of stored chatter for this room. Chatter is defined as any text that the Mud/MOO generated that was not attributed to a command that the robot executed.
Returns:
chatter a String array of chatter that was previously heard in this room.

addContents

public void addContents(java.lang.String c)
This routine adds contents to the list of contents for this room. Content items are from the list that the Mud/MOO sent in the description of the room.
Parameters:
c - the content item to be added to the list.

getContents

public java.lang.String[] getContents()
This routine returns a list of contents that were seen in this room.
Returns:
contents an array of contents that were found in this room.

setUsePossibleExits

public void setUsePossibleExits(boolean usePossibleExits)
This routine sets whether or not possible exits are used in finding exits in the room. There are three types of exits for any given room:

  1. Shown Exits
    These are exits that are shown in the description of the room that is returned by the Mud/MOO.

    Possible Exits
    These are exits that are typically derived from a description of the room.

    Fallback Exits
    These are exits that are defined by the programmer or user and are used when all other exits are exhausted. These exits are especially useful when a Mud/MOO version is being used where minimal descriptions are available and/or when the parsing algorithm is not tuned for the particular Mud/MOO.
Parameters:
usePossibleExits - if true use possible exits, if false do not use possible exits in finding exits in this room.

getUsePossibleExits

public boolean getUsePossibleExits()
This routine returns whether or not possible exits should be used in finding exits in the room.
Returns:
usePossibleExits use possible exits or not.

setUseFallbackExits

public void setUseFallbackExits(boolean useFallbackExits)
This routine sets whether or not fallback exits are used in finding exits in the room. There are three types of exits for any given room:

  1. Shown Exits
    These are exits that are shown in the description of the room that is returned by the Mud/MOO.

    Possible Exits
    These are exits that are typically derived from a description of the room.

    Fallback Exits
    These are exits that are defined by the programmer or user and are used when all other exits are exhausted. These exits are especially useful when a Mud/MOO version is being used where minimal descriptions are available and/or when the parsing algorithm is not tuned for the particular Mud/MOO.
Parameters:
useFallbackExits - if true use fallback exits, if false do not use fallback exits in finding exits in this room.

getUseFallbackExits

public boolean getUseFallbackExits()
This routine returns whether or not fallback exits should be used in finding exits in the room.
Returns:
useFallbackExits use fallback exits or not.

setFallbackExits

public void setFallbackExits(java.lang.String[] fallbackExits)
This routine sets the fallback exits.
Parameters:
fallbackExits - a list of exits to try, for example a typical list of fallback exits might include:

  • north
  • south
  • east
  • west
  • n
  • s
  • e
  • w
  • forward
  • backward
  • up
  • down
  • left
  • right

getFallbackExits

public java.lang.String[] getFallbackExits()
This routine returns the list of fallback exits.
Returns:
fallbackExits the list of fallback exits.

hasUnexploredExits

public boolean hasUnexploredExits()
This routine determines if this room has any unexplored exits.
Returns:
true there are unexplored exits in this room, if false there are no more unexplored exits in this room.

getNextUnexploredExit

public java.lang.String getNextUnexploredExit()
This routine returns the next unexplored exit for this room if one exits.
Returns:
String the name of the next unexplored exit in this room if null this room has no, or no more, unexplored exits.

hasUnvisitedExits

public boolean hasUnvisitedExits()
Deprecated.  


getNextUnvisitedExit

public Exit getNextUnvisitedExit()
Deprecated.  


getExit

public Exit getExit(int e)
This routine returns an exit that points to a specific room.
Parameters:
e - the identifier of the room that the exit should point to.
Returns:
an exit object that points to the specific room, or null this room does not have an exit that points to the specific room.

exitExists

public boolean exitExists(int e)
This routine determines if this room has an exit that points to a specific room.
Parameters:
e - the identifier of the room that the exit should point to.
Returns:
true there is an exit in this room that points to the specific room, false this is not an exit in this room that points the the specific room.

setShownExits

public void setShownExits(java.lang.String[] shownExits)
This routine sets the shown exits for this room. There are three types of exits for any given room:

  1. Shown Exits
    These are exits that are shown in the description of the room that is returned by the Mud/MOO.

    Possible Exits
    These are exits that are typically derived from a description of the room.

    Fallback Exits
    These are exits that are defined by the programmer or user and are used when all other exits are exhausted. These exits are especially useful when a Mud/MOO version is being used where minimal descriptions are available and/or when the parsing algorithm is not tuned for the particular Mud/MOO.
Parameters:
shownExits - a list of exits that were shown in the Mud/MOO description for this room.

getShownExits

public java.lang.String[] getShownExits()
This routine returns the shown exits for this room.
Returns:
shownExits a list of exits that were shown in the Mud/MOO description for this room.

setPossibleExits

public void setPossibleExits(java.lang.String[] possibleExits)
This routine sets the possible exits for this room. There are three types of exits for any given room:

  1. Shown Exits
    These are exits that are shown in the description of the room that is returned by the Mud/MOO.

    Possible Exits
    These are exits that are typically derived from a description of the room.

    Fallback Exits
    These are exits that are defined by the programmer or user and are used when all other exits are exhausted. These exits are especially useful when a Mud/MOO version is being used where minimal descriptions are available and/or when the parsing algorithm is not tuned for the particular Mud/MOO.
Parameters:
possibleExits - a list of exits that were derived from the Mud/MOO description for this room.

getPossibleExits

public java.lang.String[] getPossibleExits()
This routine returns the possible exits for this room.
Returns:
shownExits a list of exits that were derived from Mud/MOO description for this room.

setCommands

public void setCommands(java.lang.String[] commands)
This routine sets the shown commands for this room. The commands are derived from the description that the Mud/MOO returns for this room.
Parameters:
commands - a list of commands for this room.

getCommands

public java.lang.String[] getCommands()
This routine returns the shown commands for this room.
Returns:
commands a list of commands that are associated with this room.

setVisited

public void setVisited(boolean visited)
Deprecated.  


getVisited

public boolean getVisited()
Deprecated.  


addGoodExit

public void addGoodExit(Exit e)
This routine adds an exit to the good exit list. A good exit is defined as an exit that goes to the expected room, contained in the toRoom field of the exit.
Parameters:
e - the exit to add to the good exit list.

addBadExit

public void addBadExit(Exit e)
This routine adds an exit to the bad exit list. A bad exit is defined as an exit that does not go to the expected room, contained in the toRoom field of the exit.
Parameters:
e - the exit to add to the bad exit list.

addSuspectExit

public void addSuspectExit(Exit e)

removeGoodExit

public void removeGoodExit(Exit e)
This routine removes an exit from the good exits list.
Parameters:
e - the exit to be removed.

removeBadExit

public void removeBadExit(Exit e)
This routine removes an exit from the bad exits list.
Parameters:
e - the exit to be removed.

moveGoodExitToSuspectExit

public void moveGoodExitToSuspectExit(Exit e)

getGoodExits

public Exit[] getGoodExits()
This routine returns the good exits that are currently known for this room.
Returns:
a list of known good exits for this room.

getBadExits

public Exit[] getBadExits()
This routine returns the bad exits that are currently known for this room.
Returns:
a list of known bad exits for this room.

getSuspectExits

public Exit[] getSuspectExits()
This routine returns the suspect exits that are currently known for this room.
Returns:
a list of known suspect exits for this room.

clearVisitedExits

public void clearVisitedExits()
Deprecated.  


setConfusingPathTo

public void setConfusingPathTo(boolean confusingPathTo)
This routine sets whether this room has a confusing path to it.
Parameters:
confusingPathTo - true if this room has a confusing path to it.

hasConfusingPathTo

public boolean hasConfusingPathTo()
This routine returns whether the path to this room is confusing.
Returns:
true if the path to this room is confusing, false otherwise.

equals

public boolean equals(Room r)
This routine determines if the room r is the same as this room. Two rooms are defined to be equal if and only if:

Parameters:
r - the room to be checked.
Returns:
true if the rooms are equal, false otherwise.

toString

public java.lang.String toString()
This routine returns the String representation for this room.
Overrides:
toString in class java.lang.Object
Returns:
the name of the room.

toMap

public java.lang.String toMap()
This routine returns the String that represents this room as a Mass NEOTEK room object.
Returns:
the string that represents this room in a MAAS-Neotek map file.

setFirstIn

public void setFirstIn(java.util.GregorianCalendar firstIn)
This routine sets the time that this room was first entered.
Parameters:
firstIn - the time this room was first entered.

getFirstIn

public java.util.GregorianCalendar getFirstIn()
This routine gets the time that this room was first entered.
Returns:
the time this room was first entered.

setLastIn

public void setLastIn(java.util.GregorianCalendar lastIn)
This routine sets the last time that this room was entered.
Parameters:
lastIn - the time this room was last entered.

getLastIn

public java.util.GregorianCalendar getLastIn()
This routine gets the last time that this room was entered.
Returns:
the last time this room was entered.

setTotalTimeIn

public void setTotalTimeIn(long totalTimeIn)
This routine sets the total time in this room.
Parameters:
totalTimeIn - the total time that the robot was in this room.

getTotalTimeIn

public long getTotalTimeIn()
This routine gets the total time in this room.
Returns:
the total time spent in this room.

shownExitsToString

public java.lang.String shownExitsToString()
This routine returns the shown exits for this room as a string.
Returns:
the shown exits for this room.

containsObject

public boolean containsObject(java.lang.String object)
This routine determines if an object is contained in this room. The object name is compared to each item on the contains list using the following regular expression: *object*.
Returns:
true if the object is contained in the contents list for this room, false otherwise.