net.bluebones.boggle
Class HumanPlayer

java.lang.Object
  extended by net.bluebones.boggle.Player
      extended by net.bluebones.boggle.HumanPlayer

public class HumanPlayer
extends Player

Represents the entire client side of Boggle.

Version:
0.3 $Revision: 1.3 $
Author:
Thomas David Baker

Constructor Summary
HumanPlayer()
          Initialises a new HumanPlayer.
 
Method Summary
 void checkResultsSend()
          Periodic check that sends results to clients if it is the appropriate time.
 NamedClient[] getClients()
          Gets the clients currently attached to this player.
 IServer getLocalServer()
          Gets the local server.
 GameId getServerGameId()
          Gets the GameId of the game running on this player's local server.
 String[] getWords()
          Gets this player's words for this turn.
 void hostGame(GameInfo gameInfo)
          Sets up this player as the host of a game.
 void info(String msg)
          Relays the specified message to the user.
 void init(char[][] letters, int timeInSecs)
          Initializes the display of this player.
 boolean isHost()
          Determines if this player is currently hosting a game.
 void problem(String msg)
          Notifies the user of the specified problem.
 void removeClients(Collection clients)
          Removes all clients in clients from this player's local (host) server.
 void results(Round round)
          Displays the results of a round to the player.
 void setConnection(ConnectionType type, String address, int clients)
          Sets the displayed connection for this player.
 void setConnection(ConnectionType type, String address, int clients, int dots)
          Sets the displayed connection for this player.
 void setLocalServer(Server server)
          Sets the local server.
 void setRubber(Rubber r)
          Set the displayed rubber information.
 void setTimer(int tenthsOfASecond)
          Sets the timer to the specified time.
 void startNetworkGame()
          Starts a network game, setting up a Server on this host or using the existing one.
 void stopGame()
          Ends the game and returns words to the host of the game.
 
Methods inherited from class net.bluebones.boggle.Player
connecting, connectingTo, createRegistry, endGame, getClient, getGame, getHostInfo, getPort, getRegistry, getRemoteServer, hostConnectionLost, joinGame, setClient, setConnecting, setGame, setHostInfo, setNotConnecting, setRegistry, setRemoteServer, startLocalGame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HumanPlayer

public HumanPlayer()
Initialises a new HumanPlayer.

Method Detail

info

public void info(String msg)
Relays the specified message to the user.

Specified by:
info in class Player
Parameters:
msg - Message to relay.

problem

public void problem(String msg)
Notifies the user of the specified problem.

Specified by:
problem in class Player
Parameters:
msg - Message to relay.

startNetworkGame

public void startNetworkGame()
Starts a network game, setting up a Server on this host or using the existing one.


stopGame

public void stopGame()
Ends the game and returns words to the host of the game.

Specified by:
stopGame in class Player

getWords

public String[] getWords()
Gets this player's words for this turn.

Specified by:
getWords in class Player
Returns:
String[] of words the player has found this turn.

hostGame

public void hostGame(GameInfo gameInfo)
Sets up this player as the host of a game.

Parameters:
gameInfo - Player-supplied host info to help set up the host.

getLocalServer

public IServer getLocalServer()
Gets the local server. null if this HumanPlayer is not currently hosting a game.

Specified by:
getLocalServer in class Player
Returns:
Local server or null.

setLocalServer

public void setLocalServer(Server server)
Sets the local server.

Specified by:
setLocalServer in class Player
Parameters:
server - Server to set as local server or null to unset.

isHost

public boolean isHost()
Determines if this player is currently hosting a game.

Returns:
boolean.

setConnection

public void setConnection(ConnectionType type,
                          String address,
                          int clients)
Sets the displayed connection for this player.

Specified by:
setConnection in class Player
Parameters:
type - ConnectionType of connection.
address - Address of host.
clients - Number of clients currently attached to this connection.

setConnection

public void setConnection(ConnectionType type,
                          String address,
                          int clients,
                          int dots)
Sets the displayed connection for this player. Includes dots to show progress in connecting.

Specified by:
setConnection in class Player
Parameters:
type - ConnectionType of connection.
address - Address of host.
clients - Number of clients currently attached to this connection.
dots - Number of dots to display after the address. For use in showing some animation while connecting.

getClients

public NamedClient[] getClients()
Gets the clients currently attached to this player.

Overrides:
getClients in class Player
Returns:
NamedClient[] of the attached clients.

removeClients

public void removeClients(Collection clients)
Removes all clients in clients from this player's local (host) server.

Parameters:
clients - Collection of clients to remove.

setRubber

public void setRubber(Rubber r)
Set the displayed rubber information.

Specified by:
setRubber in class Player
Parameters:
r - Rubber information to set.

setTimer

public void setTimer(int tenthsOfASecond)
Sets the timer to the specified time. Measured in 10ths of a second.

Specified by:
setTimer in class Player
Parameters:
tenthsOfASecond - Amount to display in tenths of a second.

init

public void init(char[][] letters,
                 int timeInSecs)
Initializes the display of this player.

Specified by:
init in class Player
Parameters:
letters - Letters to initialize the board with.
timeInSecs - Duration of game in seconds.

results

public void results(Round round)
Displays the results of a round to the player.

Specified by:
results in class Player
Parameters:
round - Round to display.

checkResultsSend

public void checkResultsSend()
Periodic check that sends results to clients if it is the appropriate time.


getServerGameId

public GameId getServerGameId()
Gets the GameId of the game running on this player's local server.

Returns:
GameId.