dk.brics.bisim.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.bisim.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.GameActionListener
          Listen on game view elements with a possible remote effect.
(package private)  class GameControllerImpl.GameGrappaAdapter
           
(package private)  class GameControllerImpl.GameMouseListener
           
 
Field Summary
private  int clientServerRole
           
private  BisimulationGame controller
           
private  GameControllerImpl.GameActionListener gameActionListener
           
private  GameControllerImpl.GameGrappaAdapter gameGrappaAdapter
           
private  GameModel gameModel
           
private  GameControllerImpl.GameMouseListener gameMouseListener
           
private  GameView gameView
           
private  boolean lonely
           
private  MessagePasser messagePasser
           
private  int myRole
           
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  void displayConfiguration()
           
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

gameActionListener

private GameControllerImpl.GameActionListener gameActionListener

gameMouseListener

private GameControllerImpl.GameMouseListener gameMouseListener
Constructor Detail

GameControllerImpl

public GameControllerImpl(BisimulationGame controller,
                          GameView gameView,
                          GameModel gameModel,
                          int myRole,
                          int clientServerRole,
                          MessagePasser messagePasser)
                   throws java.rmi.RemoteException,
                          javax.swing.text.BadLocationException
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
javax.swing.text.BadLocationException
Method Detail

setupListeners

private void setupListeners()

prepareGameView

private void prepareGameView()
                      throws javax.swing.text.BadLocationException
Throws:
javax.swing.text.BadLocationException - Should never be thrown

attackerChoseSide

private void attackerChoseSide(int side,
                               java.lang.String message)
                        throws javax.swing.text.BadLocationException
Parameters:
side - A side
message - A message
Throws:
javax.swing.text.BadLocationException - Should never be thrown

attackerStep

private void attackerStep(java.lang.String action,
                          java.lang.String nodeName,
                          java.lang.String message)
                   throws javax.swing.text.BadLocationException
Parameters:
action - Attacker's action
nodeName - Name of to-node
message - A message
Throws:
javax.swing.text.BadLocationException - Should never be thrown

defenderStep

private void defenderStep(java.lang.String nodeName)
                   throws javax.swing.text.BadLocationException
Parameters:
nodeName - Name of to-node
Throws:
javax.swing.text.BadLocationException - Should never be thrown

resetGame

private void resetGame()
                throws javax.swing.text.BadLocationException
Throws:
javax.swing.text.BadLocationException - Should never be thrown

displayConfiguration

private void displayConfiguration()
                           throws javax.swing.text.BadLocationException
Throws:
javax.swing.text.BadLocationException - Should never be thrown

updateStatus

public void updateStatus(int messageNumber,
                         java.lang.String message)
                  throws java.rmi.RemoteException
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
Throws:
java.rmi.RemoteException
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