bluegammon.logic
Class RemotePlayer

java.lang.Object
  extended bybluegammon.logic.Player
      extended bybluegammon.logic.RemotePlayer
All Implemented Interfaces:
PlayerListener, java.lang.Runnable

public class RemotePlayer
extends Player
implements PlayerListener, java.lang.Runnable

Represents a player that is on the other side of a connection; a remote player does not have access to this device.

This RemotePlayer is also a PlayerListener and retreives events from a LocalPlayer remotely sent from a PlayerListenerProxy via streams. It then deparses remote data and calls appropriate action on the BoardMediator.

Author:
Peter Andersson

Field Summary
 
Fields inherited from interface bluegammon.logic.PlayerListener
LOCAL_GIVE_UP, LOCAL_QUIT, REMOTE_GIVE_UP, REMOTE_QUIT
 
Constructor Summary
RemotePlayer(int id, char[] name, boolean white, java.io.DataInputStream in)
          Creates a remote player.
 
Method Summary
 void gameExited(int id, int reason)
          Called when a game exit event is received.
 void messageSent(int id, char[] msg)
          Called when a message event is received.
 void moveMade(int id, int moveIndex)
          Called when a move made event is received.
 void run()
          Runnable implementation, reading data from the input stream and deserializes the events.
 void turnCommit(int id)
          Called when a turn commit event is received.
 void undoPerformed(int id)
          Called when an undo performed event is received.
 
Methods inherited from class bluegammon.logic.Player
addListener, getId, getName, init, isWhite, setWhite
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemotePlayer

public RemotePlayer(int id,
                    char[] name,
                    boolean white,
                    java.io.DataInputStream in)
Creates a remote player.

Parameters:
id - The id of the remote player.
name - The name of the remote player.
white - The color of the remote player, true for white, false for black.
in - The stream the remote player is reading events from.
Method Detail

moveMade

public void moveMade(int id,
                     int moveIndex)
Called when a move made event is received.

Specified by:
moveMade in interface PlayerListener
Parameters:
id - Player id.
moveIndex - The moveindex in possible move array used for move.

undoPerformed

public void undoPerformed(int id)
Called when an undo performed event is received.

Specified by:
undoPerformed in interface PlayerListener
Parameters:
id - Player id.

turnCommit

public void turnCommit(int id)
Called when a turn commit event is received.

Specified by:
turnCommit in interface PlayerListener
Parameters:
id - Player id.

messageSent

public void messageSent(int id,
                        char[] msg)
Called when a message event is received.

Specified by:
messageSent in interface PlayerListener
Parameters:
id - Player id.
msg - The message.

gameExited

public void gameExited(int id,
                       int reason)
Called when a game exit event is received.

Specified by:
gameExited in interface PlayerListener
Parameters:
id - Player id.
reason - The reason for exiting game.

run

public void run()
Runnable implementation, reading data from the input stream and deserializes the events.

Specified by:
run in interface java.lang.Runnable