games.strategy.engine.framework
Class ServerGame

java.lang.Object
  extended by games.strategy.engine.framework.ServerGame
All Implemented Interfaces:
IGame

public class ServerGame
extends java.lang.Object
implements IGame

Author:
Sean Bridges Represents a running game. Lookups to get a GamePlayer from PlayerId and the current Delegate.

Field Summary
static java.lang.String DISPLAY_CHANNEL
           
static RemoteName SERVER_REMOTE
           
 
Fields inherited from interface games.strategy.engine.framework.IGame
GAME_MODIFICATION_CHANNEL
 
Constructor Summary
ServerGame(GameData data, java.util.Set<IGamePlayer> localPlayers, java.util.Map<java.lang.String,INode> remotePlayerMapping, Messengers messengers)
           
 
Method Summary
 void addChange(Change aChange)
          Should not be called outside of engine code.
 void addDelegateMessenger(IDelegate delegate)
           
 void addDisplay(IDisplay display)
          add a display that will recieve broadcasts from the IDelegateBridge.getDisplayBroadvaster
 void addGameStepListener(GameStepListener listener)
           
 void addObserver(IObserverWaitingToJoin observer)
           
 boolean canSave()
           
 IChannelMessenger getChannelMessenger()
           
 GameData getData()
           
static RemoteName getDisplayChannel(GameData data)
           
 InGameLobbyWatcher getInGameLobbyWatcher()
           
 IMessenger getMessenger()
           
 PlayerManager getPlayerManager()
           
 IRandomSource getRandomSource()
           
 IRemoteMessenger getRemoteMessenger()
           
static RemoteName getRemoteName(IDelegate delegate)
           
static RemoteName getRemoteName(PlayerID id, GameData data)
           
static RemoteName getRemoteRandomName(PlayerID id)
           
 Vault getVault()
           
 boolean isGameOver()
          Is the game over.
 boolean isGameSequenceRunning()
           
 void removeDisplay(IDisplay display)
          remove a display
 void removeGameStepListener(GameStepListener listener)
           
 void saveGame(java.io.File f)
          Save the game to the given directory.
 void saveGame(java.io.OutputStream out)
           
 void setInGameLobbyWatcher(InGameLobbyWatcher inGameLobbyWatcher)
           
 void setRandomSource(IRandomSource randomSource)
           
 void startGame()
          And here we go.
 void stopGame()
           
 void stopGameSequence()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPLAY_CHANNEL

public static final java.lang.String DISPLAY_CHANNEL
See Also:
Constant Field Values

SERVER_REMOTE

public static final RemoteName SERVER_REMOTE
Constructor Detail

ServerGame

public ServerGame(GameData data,
                  java.util.Set<IGamePlayer> localPlayers,
                  java.util.Map<java.lang.String,INode> remotePlayerMapping,
                  Messengers messengers)
Parameters:
localPlayers - Set - A set of GamePlayers
messenger - IServerMessenger
remotePlayerMapping - Map
Method Detail

getDisplayChannel

public static RemoteName getDisplayChannel(GameData data)

addObserver

public void addObserver(IObserverWaitingToJoin observer)

addDelegateMessenger

public void addDelegateMessenger(IDelegate delegate)

getRemoteName

public static RemoteName getRemoteName(IDelegate delegate)

getRemoteName

public static RemoteName getRemoteName(PlayerID id,
                                       GameData data)

getRemoteRandomName

public static RemoteName getRemoteRandomName(PlayerID id)

getData

public GameData getData()
Specified by:
getData in interface IGame

startGame

public void startGame()
And here we go. Starts the game in a new thread


stopGame

public void stopGame()

saveGame

public void saveGame(java.io.File f)
Description copied from interface: IGame
Save the game to the given directory. The file should exist and be writeable.

Specified by:
saveGame in interface IGame

saveGame

public void saveGame(java.io.OutputStream out)
              throws java.io.IOException
Throws:
java.io.IOException

addGameStepListener

public void addGameStepListener(GameStepListener listener)
Specified by:
addGameStepListener in interface IGame

removeGameStepListener

public void removeGameStepListener(GameStepListener listener)
Specified by:
removeGameStepListener in interface IGame

getMessenger

public IMessenger getMessenger()
Specified by:
getMessenger in interface IGame

getChannelMessenger

public IChannelMessenger getChannelMessenger()
Specified by:
getChannelMessenger in interface IGame

getRemoteMessenger

public IRemoteMessenger getRemoteMessenger()
Specified by:
getRemoteMessenger in interface IGame

addChange

public void addChange(Change aChange)
Description copied from interface: IGame
Should not be called outside of engine code.

Specified by:
addChange in interface IGame

canSave

public boolean canSave()
Specified by:
canSave in interface IGame

getRandomSource

public IRandomSource getRandomSource()
Specified by:
getRandomSource in interface IGame

setRandomSource

public void setRandomSource(IRandomSource randomSource)

getVault

public Vault getVault()
Specified by:
getVault in interface IGame

addDisplay

public void addDisplay(IDisplay display)
Description copied from interface: IGame
add a display that will recieve broadcasts from the IDelegateBridge.getDisplayBroadvaster

Specified by:
addDisplay in interface IGame

removeDisplay

public void removeDisplay(IDisplay display)
Description copied from interface: IGame
remove a display

Specified by:
removeDisplay in interface IGame

isGameOver

public boolean isGameOver()
Description copied from interface: IGame
Is the game over. Game over does not relate to the state of the game (eg check-mate in chess) but to the game being shut down and all players have left.

Specified by:
isGameOver in interface IGame

getPlayerManager

public PlayerManager getPlayerManager()
Specified by:
getPlayerManager in interface IGame
Returns:
a listing of who is playing who.

getInGameLobbyWatcher

public InGameLobbyWatcher getInGameLobbyWatcher()

setInGameLobbyWatcher

public void setInGameLobbyWatcher(InGameLobbyWatcher inGameLobbyWatcher)

stopGameSequence

public void stopGameSequence()

isGameSequenceRunning

public boolean isGameSequenceRunning()