games.strategy.engine.delegate
Class DefaultDelegateBridge

java.lang.Object
  extended by games.strategy.engine.delegate.DefaultDelegateBridge
All Implemented Interfaces:
IDelegateBridge

public class DefaultDelegateBridge
extends java.lang.Object
implements IDelegateBridge

Default implementation of DelegateBridge

Author:
Sean Bridges

Constructor Summary
DefaultDelegateBridge(GameData data, IGame game, IDelegateHistoryWriter historyWriter, RandomStats randomStats, DelegateExecutionManager delegateExecutionManager)
          Creates new DefaultDelegateBridge
 
Method Summary
 void addChange(Change aChange)
          Add a change to game data.
 void enterDelegateExecution()
           
 IChannelSubscribor getDisplayChannelBroadcaster()
          Return an object that implements the IDisplay interface for the game.
 IDelegateHistoryWriter getHistoryWriter()
          return the delegate history writer for this game.
 PlayerID getPlayerID()
           
 int[] getRandom(int max, int count, java.lang.String annotation)
          Delegates should not use random data that comes from any other source.
 int getRandom(int max, java.lang.String annotation)
          All delegates should use random data that comes from both players so that neither player cheats.
 IRemote getRemote()
          equivalent to getRemote(getPlayerID())
 IRemote getRemote(PlayerID id)
          Get a remote reference to the given player.
 java.lang.String getStepName()
          Returns the current step name
 java.util.Properties getStepProperties()
           
 void leaveDelegateExecution()
           
 void setRandomSource(IRandomSource randomSource)
           
 void stopGameSequence()
          After this step finishes executing, the next delegate will not be called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDelegateBridge

public DefaultDelegateBridge(GameData data,
                             IGame game,
                             IDelegateHistoryWriter historyWriter,
                             RandomStats randomStats,
                             DelegateExecutionManager delegateExecutionManager)
Creates new DefaultDelegateBridge

Method Detail

getPlayerID

public PlayerID getPlayerID()
Specified by:
getPlayerID in interface IDelegateBridge

setRandomSource

public void setRandomSource(IRandomSource randomSource)

getRandom

public int getRandom(int max,
                     java.lang.String annotation)
All delegates should use random data that comes from both players so that neither player cheats.

Specified by:
getRandom in interface IDelegateBridge

getRandom

public int[] getRandom(int max,
                       int count,
                       java.lang.String annotation)
Delegates should not use random data that comes from any other source.

Specified by:
getRandom in interface IDelegateBridge
annotation - - a string used to describe the random event.


addChange

public void addChange(Change aChange)
Description copied from interface: IDelegateBridge
Add a change to game data. Use this rather than changing gameData directly since this method allows us to send the changes to other machines.

Specified by:
addChange in interface IDelegateBridge

getStepName

public java.lang.String getStepName()
Returns the current step name

Specified by:
getStepName in interface IDelegateBridge

getHistoryWriter

public IDelegateHistoryWriter getHistoryWriter()
Description copied from interface: IDelegateBridge
return the delegate history writer for this game.

The delegate history writer allows writing to the game history.

Specified by:
getHistoryWriter in interface IDelegateBridge

getRemote

public IRemote getRemote()
Description copied from interface: IDelegateBridge
equivalent to getRemote(getPlayerID())

Specified by:
getRemote in interface IDelegateBridge
Returns:
remote for the current player.

getRemote

public IRemote getRemote(PlayerID id)
Description copied from interface: IDelegateBridge
Get a remote reference to the given player.

Specified by:
getRemote in interface IDelegateBridge
See Also:
IRemoteMessenger

getDisplayChannelBroadcaster

public IChannelSubscribor getDisplayChannelBroadcaster()
Description copied from interface: IDelegateBridge
Return an object that implements the IDisplay interface for the game.

Methods called on this returned object will be invoked on all displays in the game, including those on remote machines

Specified by:
getDisplayChannelBroadcaster in interface IDelegateBridge

getStepProperties

public java.util.Properties getStepProperties()
Specified by:
getStepProperties in interface IDelegateBridge
Returns:
the propertie for this step.


leaveDelegateExecution

public void leaveDelegateExecution()
Specified by:
leaveDelegateExecution in interface IDelegateBridge

enterDelegateExecution

public void enterDelegateExecution()
Specified by:
enterDelegateExecution in interface IDelegateBridge

stopGameSequence

public void stopGameSequence()
Description copied from interface: IDelegateBridge
After this step finishes executing, the next delegate will not be called.

This methd allows the delegate to signal that the game is over, but does not force the ui or the display to shutdown.

Specified by:
stopGameSequence in interface IDelegateBridge