dk.brics.bisimulationGame.controller
Class GameControllerImpl

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by dk.brics.bisimulationGame.controller.GameControllerImpl
All Implemented Interfaces:
GameController, java.io.Serializable, java.rmi.Remote

public class GameControllerImpl
extends java.rmi.server.UnicastRemoteObject
implements GameController

Implementation of the GameController.

Author:
Martin Mosegaard martinm@daimi.au.dk
See Also:
GameController, Serialized Form

Nested Class Summary
(package private)  class GameControllerImpl.GameGrappaAdapter
           
(package private)  class GameControllerImpl.RemoteActionListener
          Listen on game view elements with a possible remote effect.
(package private)  class GameControllerImpl.RemoteMouseListener
           
 
Field Summary
private  int clientServerRole
           
private  BisimulationGame controller
           
private  GameControllerImpl.GameGrappaAdapter gameGrappaAdapter
          Listeners
private  GameModel gameModel
           
private  GameView gameView
           
private  boolean lonely
           
private  MessagePasser messagePasser
           
private  int myRole
           
private  GameControllerImpl.RemoteActionListener remoteActionListener
           
private  GameControllerImpl.RemoteMouseListener remoteMouseListener
           
private static long serialVersionUID
           
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
GameControllerImpl(BisimulationGame controller, GameView gameView, GameModel gameModel, int myRole, int clientServerRole, MessagePasser messagePasser)
          Constructs a game controller.
 
Method Summary
private  void attackerChoseSide(int side, java.lang.String message)
           
private  void attackerStep(java.lang.String action, java.lang.String nodeName, java.lang.String message)
           
private  void defenderStep(java.lang.String nodeName)
           
private  java.lang.String getRoleMessage()
           
private  void prepareGameView()
           
 void quit()
          Invoked by the message passer when the other player wants to quit.
private  void resetGame()
           
 void setChatMessage(java.lang.String message)
          Invoked by the message passer when the other player sends a chat message.
private  void setupListeners()
           
 void updateStatus(int messageNumber, java.lang.String message)
          Invoked by the message passer when status has changed by another players move.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

myRole

private int myRole

clientServerRole

private int clientServerRole

gameModel

private GameModel gameModel

gameView

private GameView gameView

controller

private BisimulationGame controller

messagePasser

private MessagePasser messagePasser

lonely

private boolean lonely

gameGrappaAdapter

private GameControllerImpl.GameGrappaAdapter gameGrappaAdapter
Listeners


remoteActionListener

private GameControllerImpl.RemoteActionListener remoteActionListener

remoteMouseListener

private GameControllerImpl.RemoteMouseListener remoteMouseListener
Constructor Detail

GameControllerImpl

public GameControllerImpl(BisimulationGame controller,
                          GameView gameView,
                          GameModel gameModel,
                          int myRole,
                          int clientServerRole,
                          MessagePasser messagePasser)
                   throws java.rmi.RemoteException
Constructs a game controller.

Parameters:
controller - A game instance
gameView - A view on which to listen on events
gameModel - A data model
myRole - As specified in the game model
clientServerRole - As specified in the game model
messagePasser - A message passer to send move messages to the other player
Throws:
java.rmi.RemoteException
Method Detail

setupListeners

private void setupListeners()

prepareGameView

private void prepareGameView()
                      throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

getRoleMessage

private java.lang.String getRoleMessage()

attackerChoseSide

private void attackerChoseSide(int side,
                               java.lang.String message)

attackerStep

private void attackerStep(java.lang.String action,
                          java.lang.String nodeName,
                          java.lang.String message)

defenderStep

private void defenderStep(java.lang.String nodeName)

resetGame

private void resetGame()

updateStatus

public void updateStatus(int messageNumber,
                         java.lang.String message)
Description copied from interface: GameController
Invoked by the message passer when status has changed by another players move. Message numbers are specified in the protocol.

Specified by:
updateStatus in interface GameController
Parameters:
messageNumber - A protocol message number
message - A message
See Also:
Protocol

quit

public void quit()
          throws java.rmi.RemoteException
Description copied from interface: GameController
Invoked by the message passer when the other player wants to quit.

Specified by:
quit in interface GameController
Throws:
java.rmi.RemoteException

setChatMessage

public void setChatMessage(java.lang.String message)
                    throws java.rmi.RemoteException
Description copied from interface: GameController
Invoked by the message passer when the other player sends a chat message.

Specified by:
setChatMessage in interface GameController
Throws:
java.rmi.RemoteException