|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Object | +--GameObject
This is the main class of objects in the game. Its instances represent tangible, rather than software, objects.
| Inner Class Summary | |
(package private) class |
GameObject.LeaveInfo
This inner class has no methods, but is used as a convenient way to keep all the information about someone leaving a Room in one convenient place. |
| Field Summary | |
protected static MasterGame |
masterGame
The MasterGame object that's running the game of which we're part. |
protected java.lang.String |
name
Object names are supposed to be unique, but this is not currently enforced. |
| Constructor Summary | |
GameObject()
|
|
| Method Summary | |
void |
announce(java.lang.String message)
If an object wants to say something, let the game handle it. |
int |
compareTo(java.lang.Object other)
Compare this object to another, for sorting purposes. |
void |
doAction()
Figure out what we want to do when we get our 15 microseconds of fame. |
static MasterGame |
getMasterGame()
Retrieve a class variable so we can find the master game object. |
void |
initialize(java.lang.String initializer,
GameObject parentObjectArg)
Initalize the object based on details in the input file, including registering it with the game and its parent. |
void |
kill()
Remove this object from the game by notifying the master game. |
void |
listen(java.lang.String message)
Listen to a message and respond. |
static GameObject |
newInstance(java.lang.String objectType,
java.lang.String initializer,
GameObject owner)
Create a new GameObject based on text information. |
static void |
setMasterGame(MasterGame argMasterGame)
Set a class variable so we can find the master game object. |
java.lang.String |
toString()
Convert the object to a string. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
protected static MasterGame masterGame
protected java.lang.String name
MasterGame.getNextName.MasterGame.getNextName(String)| Constructor Detail |
public GameObject()
| Method Detail |
public void announce(java.lang.String message)
message - Sentence the object wants to say. These are generally accumulated
and displayed at checkpoints.public int compareTo(java.lang.Object other)
compareTo in interface java.lang.Comparableother - typed as an Object to meet the requirements of
the Comparable interface, but this method will Throw
a ClassCastException it isn't really a GameObject.public void doAction()
public static MasterGame getMasterGame()
public void initialize(java.lang.String initializer,
GameObject parentObjectArg)
throws GameException
initializer - Not used here, only by subclasses. It's a String now, but
I think that the calling method should split it up into an array. It would
make the code much easier here.parentObjectArg - What this is contained inside.
Generally null for Rooms and Passages.GameException - The superclass never does, but declared this way
to allow for subclasses to throw it.public void kill()
public void listen(java.lang.String message)
message - English message telling the object what to do.
The messages was probably typed
in by a user, but could also have been a request by some
other object during its doAction time.
public static GameObject newInstance(java.lang.String objectType,
java.lang.String initializer,
GameObject owner)
throws CantCreateObjectException
objectType - the object type, currently the same as
the class name)initializer - tilde-delimited initialization stringowner - the owner of this objectCantCreateObjectException - if the objectType is not a valid class name,
if the class is not a descendant of GameObject, or if the initialize()
method throws an exception.public static void setMasterGame(MasterGame argMasterGame)
public java.lang.String toString()
toString in class java.lang.Objectclass + name for
debugging purposes, but I like the convenience of being able,
in effect, to use a GameObject as a string without peppering
the code with getName() calls.
|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||