org.vizzini.game
Class AbstractEnvironment

java.lang.Object
  extended by org.vizzini.game.AbstractEnvironment
All Implemented Interfaces:
Serializable, Cloneable, IEnvironment
Direct Known Subclasses:
AbstractArcadeEnvironment, AbstractCardTable, AbstractGridBoard, AbstractSimulationEnvironment, DefaultEnvironment

public abstract class AbstractEnvironment
extends Object
implements IEnvironment

Provides base functionality for environments in the game framework. An environment instance encapsulates the environment in which actions occur in a game, and tracks the effects of those actions. Examples of environments include a chess board, a card table, or deep space.

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Constructor Summary
AbstractEnvironment()
          Construct this object with no agents.
AbstractEnvironment(AbstractEnvironment another)
          Copy constructor.
 
Method Summary
 void addStateListener(IStateListener listener)
          Add the given listener.
 Object clone()
          Return a clone of this instance.
 void configure(Properties properties)
          Configure this environment.
 void copy(IEnvironment environment)
          Copy data from the given instance into this.
protected  ITokenCollection createInitialTokens()
          Create the initial tokens from the cached properties.
 boolean equals(Object object)
          Return true if the given object is equal to this.
 IToken get(IPosition position)
          Return the token at the given position.
 IAdjudicator getAdjudicator()
          Return the adjudicator.
 IAgentCollection getAgentCollection()
          Return the agent collection.
protected  StateManager getStateManager()
          Return the state manager.
 ITeamCollection getTeamCollection()
          Return the team collection.
 ITokenCollection getTokenCollection()
          Return the token collection.
protected  Class getTokenCollectionClass()
           
 long getTurnNumber()
          Return the current turn number.
 int hashCode()
          Returns a hash code value for the object.
 void incrementTurnNumber()
          Increment the turn number.
 boolean isFiringStateChanges()
          Return true if this is set to fire state change events.
 void open(IGameState gameState)
          Open the game contained in the given game state.
 void performActions(Collection actions)
          Perform the actions in the given list.
 void removeStateListener(IStateListener listener)
          Remove the given listener.
 void reset()
          Reset to the initial state.
 void setAdjudicator(IAdjudicator adjudicator)
          Set the adjudicator.
 void setAgentCollection(IAgentCollection agentCollection)
          Set the agent collection.
 void setFiringStateChanges(boolean fire)
          Set the flag which indicates whether to fire state change events.
protected  void setTokenCollectionClass(Class tokenCollectionClass)
           
 void setTurnNumber(long turnNumber)
          Set the turn number to the given value.
 void update(long deltaTime)
          Update the environment for the given elapsed time.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.vizzini.game.IEnvironment
performAction, undoAction
 

Constructor Detail

AbstractEnvironment

public AbstractEnvironment()
Construct this object with no agents.

Since:
v0.1

AbstractEnvironment

public AbstractEnvironment(AbstractEnvironment another)
Copy constructor.

Parameters:
another - The environment from which to copy.
Since:
v0.1
Method Detail

addStateListener

public void addStateListener(IStateListener listener)
Add the given listener.

Specified by:
addStateListener in interface IEnvironment
Since:
v0.1

clone

public Object clone()
Return a clone of this instance.

Specified by:
clone in interface IEnvironment
Overrides:
clone in class Object
Since:
v0.1

configure

public void configure(Properties properties)
               throws InstantiationException,
                      IllegalAccessException
Configure this environment.

Specified by:
configure in interface IEnvironment
Parameters:
properties - Source of configuration information.
Throws:
InstantiationException
IllegalAccessException
Since:
v0.1

copy

public void copy(IEnvironment environment)
Copy data from the given instance into this.

Specified by:
copy in interface IEnvironment
Parameters:
environment - Environment from which to copy data.
Since:
v0.1

equals

public boolean equals(Object object)
Return true if the given object is equal to this.

Overrides:
equals in class Object
Parameters:
object - The object to compare.
Since:
v0.2

get

public IToken get(IPosition position)
Return the token at the given position.

Specified by:
get in interface IEnvironment
Since:
v0.2

getAdjudicator

public IAdjudicator getAdjudicator()
Return the adjudicator.

Specified by:
getAdjudicator in interface IEnvironment
Since:
v0.1

getAgentCollection

public IAgentCollection getAgentCollection()
Return the agent collection.

Specified by:
getAgentCollection in interface IEnvironment
Since:
v0.1

getTeamCollection

public ITeamCollection getTeamCollection()
Return the team collection.

Specified by:
getTeamCollection in interface IEnvironment
Since:
v0.1

getTokenCollection

public ITokenCollection getTokenCollection()
Return the token collection.

Specified by:
getTokenCollection in interface IEnvironment
Since:
v0.1

getTurnNumber

public long getTurnNumber()
Return the current turn number.

Specified by:
getTurnNumber in interface IEnvironment
Since:
v0.1

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class Object
Since:
v0.2

incrementTurnNumber

public void incrementTurnNumber()
Increment the turn number.

Specified by:
incrementTurnNumber in interface IEnvironment
Since:
v0.1

isFiringStateChanges

public boolean isFiringStateChanges()
Return true if this is set to fire state change events.

Specified by:
isFiringStateChanges in interface IEnvironment
Since:
v0.2

open

public void open(IGameState gameState)
Open the game contained in the given game state.

Specified by:
open in interface IEnvironment
Since:
v0.1

performActions

public void performActions(Collection actions)
Perform the actions in the given list.

Specified by:
performActions in interface IEnvironment
Parameters:
actions - List of actions.
Since:
v0.1

removeStateListener

public void removeStateListener(IStateListener listener)
Remove the given listener.

Specified by:
removeStateListener in interface IEnvironment
Since:
v0.1

reset

public void reset()
Reset to the initial state.

Specified by:
reset in interface IEnvironment
Since:
v0.1

setAdjudicator

public void setAdjudicator(IAdjudicator adjudicator)
Set the adjudicator.

Specified by:
setAdjudicator in interface IEnvironment
Parameters:
adjudicator - The new adjudicator.
Since:
v0.1

setAgentCollection

public void setAgentCollection(IAgentCollection agentCollection)
Set the agent collection.

Specified by:
setAgentCollection in interface IEnvironment
Parameters:
agentCollection - New agent collection.
Since:
v0.1

setFiringStateChanges

public void setFiringStateChanges(boolean fire)
Set the flag which indicates whether to fire state change events.

Specified by:
setFiringStateChanges in interface IEnvironment
Since:
v0.1

setTurnNumber

public void setTurnNumber(long turnNumber)
Set the turn number to the given value.

Specified by:
setTurnNumber in interface IEnvironment
Since:
v0.1

update

public void update(long deltaTime)
Update the environment for the given elapsed time. The base class method has no action.

Specified by:
update in interface IEnvironment
Parameters:
deltaTime - Delta time per cycle. (ms)
Since:
v0.1

createInitialTokens

protected ITokenCollection createInitialTokens()
                                        throws InstantiationException,
                                               IllegalAccessException
Create the initial tokens from the cached properties.

Throws:
InstantiationException
IllegalAccessException
Since:
v0.1

getStateManager

protected StateManager getStateManager()
Return the state manager.


getTokenCollectionClass

protected Class getTokenCollectionClass()
Returns:
Return tokenCollectionClass.

setTokenCollectionClass

protected void setTokenCollectionClass(Class tokenCollectionClass)
Parameters:
tokenCollectionClass - The tokenCollectionClass to set.


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02