monrovia.server.platform
Class GameObject

java.lang.Object
  |
  +--monrovia.server.platform.GameObject
Direct Known Subclasses:
Azoic, Command, Creature, Ground

public abstract class GameObject
extends java.lang.Object

Abstract base class for all game objects. This includes at least map objects and commands.


Constructor Summary
protected GameObject()
          Constructor.
 
Method Summary
 void addParameter(java.lang.String pKey, java.lang.Class pType)
          Add a parameter.
 void addParameters(ParameterMap pParameters)
          This method will be called to initialize the parameters.
 void checkParameters(ParameterMap pParameters)
          This method will be called to check the parameters.
static void clearCommandMarks()
          This is called after a turn to clear the marks that has been set in that turn.
static GameObject create(GameObjectData pData)
          Create new GameObject from given data.
 java.lang.String getArea()
          Get the area where this object is currently located.
 Command getCommandMark(java.lang.String pKey)
          Get the command object that has set a mark.
 GameInterface getGI()
          Shorter method to get the GameInterface instance.
 int getID()
          Get the GameObject ID.
 IntPoint getLocation()
          Get the location of this object in the current map area.
 java.lang.String getName()
          Get the name of this object.
 java.util.List getNeededParameters()
          Returns a list of parameters that are needed.
 java.util.List getOptionalParameters()
          Returns a list of optional parameters.
 java.lang.Object getParameter(java.lang.String pKey)
          Get value for given parameter.
 void initialize()
          Called when this object is really created.
 java.lang.Object removeParameter(java.lang.String pKey)
          Remove a parameter.
 void resetObject()
          Place for the game implementor to reset needed stuff.
 void resetParameters()
          Reset the parameters to the situation after initialize().
 void setCommandMark(java.lang.String pKey, Command pCommand)
          Commands can set marks with this method to find out conflicts with other commands.
 void setParameter(java.lang.String pKey, java.lang.Object pValue)
          Set the value for a parameter.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GameObject

protected GameObject()
Constructor. Do not use this for creating game objects. Use the GameObjectData.create() instead.
Method Detail

getGI

public GameInterface getGI()
Shorter method to get the GameInterface instance.

addParameters

public void addParameters(ParameterMap pParameters)
This method will be called to initialize the parameters.

Parameters:
pParameters - Add the parameters here

getNeededParameters

public java.util.List getNeededParameters()
Returns a list of parameters that are needed. No checking is done based on this list. Checking should be done in the checkParameters() method. This method is used when we need to query the parameters from the user for example when adding a player.

getOptionalParameters

public java.util.List getOptionalParameters()
Returns a list of optional parameters. This is used to tell what parameters the user can set for example when adding a player.

checkParameters

public void checkParameters(ParameterMap pParameters)
                     throws StorageException
This method will be called to check the parameters.

Parameters:
pParameters - Check that the parameters are OK
Throws:
StorageException - Throw this if you find an error.

create

public static GameObject create(GameObjectData pData)
Create new GameObject from given data.

Parameters:
pData - Data object for the new object
Returns:
New GameObject

initialize

public void initialize()
Called when this object is really created. The parameters are in the place for the first time in this point. After this the parameters are cloned for possible reset.

getID

public final int getID()
Get the GameObject ID.

getName

public final java.lang.String getName()
Get the name of this object.

getParameter

public final java.lang.Object getParameter(java.lang.String pKey)
Get value for given parameter.

addParameter

public final void addParameter(java.lang.String pKey,
                               java.lang.Class pType)
Add a parameter.

setParameter

public final void setParameter(java.lang.String pKey,
                               java.lang.Object pValue)
Set the value for a parameter.

removeParameter

public final java.lang.Object removeParameter(java.lang.String pKey)
Remove a parameter.

resetParameters

public final void resetParameters()
Reset the parameters to the situation after initialize().

resetObject

public void resetObject()
Place for the game implementor to reset needed stuff.

getLocation

public final IntPoint getLocation()
Get the location of this object in the current map area.

getArea

public final java.lang.String getArea()
Get the area where this object is currently located.

setCommandMark

public void setCommandMark(java.lang.String pKey,
                           Command pCommand)
Commands can set marks with this method to find out conflicts with other commands. The place to use this is Command.tryExecution().

Parameters:
pKey - Key for the mark
pCommand - Command object that is setting this mark.

getCommandMark

public Command getCommandMark(java.lang.String pKey)
Get the command object that has set a mark.

Returns:
Command object or null

clearCommandMarks

public static void clearCommandMarks()
This is called after a turn to clear the marks that has been set in that turn.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object