uk.org.redfelineninja.risk.server
Class RiskClientWriter

java.lang.Object
  |
  +--java.io.Writer
        |
        +--java.io.PrintWriter
              |
              +--uk.org.redfelineninja.risk.server.RiskClientWriter
All Implemented Interfaces:
RiskClientInterface

public class RiskClientWriter
extends java.io.PrintWriter
implements RiskClientInterface

This class provides the network output hooks required by the server. The RiskServerInterface proved to be insufficient so we have extended from writer as well.


Constructor Summary
RiskClientWriter(java.io.Writer network, java.util.Hashtable pR)
           
 
Method Summary
 void error(java.lang.String err)
          Report an error only to the active player.
 void gameOver(Player victor)
          Called when the game is won.
 void gameOver(Player player, java.lang.String reason)
          Called when the game is stopped by the server.
 void lostPlayer(Player player)
          Called when a player leaves the game (or if his connection is timed out).
 void message(java.lang.String message)
          Message sent over the chat system to all clients.
 void newGame(Player[] players)
          Called when the games owner decides to stop waiting for new players and start playing.
 void newPlayer(Player player)
          Called when a new player has joined the game the client is waiting to play
 void newSpectator(Player player)
          Called whenever a new spectator has joined the game.
 void select(java.lang.String country)
          Set the selection to the country.
 void setArmies(java.lang.String country, int a)
          Set the number of armies in a country.
 void setCards(Card[] cards)
          Tell the client the cards that the player has.
 void setDice(int[] die)
          Supply the current state of the dice to those it interests.
 void setOwner(java.lang.String country, Player player)
          Set the owner of the country to the player.
 void setTurn(Player player)
          It is player's turn
 void showStatus(java.lang.String status)
          Display the supplied string in the clients status line.
 
Methods inherited from class java.io.PrintWriter
checkError, close, flush, print, print, print, print, print, print, print, print, print, println, println, println, println, println, println, println, println, println, println, write, write, write, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RiskClientWriter

public RiskClientWriter(java.io.Writer network,
                        java.util.Hashtable pR)
Method Detail

error

public void error(java.lang.String err)
Report an error only to the active player.


newPlayer

public void newPlayer(Player player)
Called when a new player has joined the game the client is waiting to play

Specified by:
newPlayer in interface RiskClientInterface

newSpectator

public void newSpectator(Player player)
Called whenever a new spectator has joined the game. This can be ignored unless the client has a talker that supports private talking. Robots could communicate their internal state like this if desired.

Specified by:
newSpectator in interface RiskClientInterface

lostPlayer

public void lostPlayer(Player player)
Called when a player leaves the game (or if his connection is timed out). Leaving mid-game is anti-social but it will happen.

Specified by:
lostPlayer in interface RiskClientInterface

newGame

public void newGame(Player[] players)
Called when the games owner decides to stop waiting for new players and start playing.

Specified by:
newGame in interface RiskClientInterface

gameOver

public void gameOver(Player victor)
Called when the game is won.

Specified by:
gameOver in interface RiskClientInterface

gameOver

public void gameOver(Player player,
                     java.lang.String reason)
Called when the game is stopped by the server.

Specified by:
gameOver in interface RiskClientInterface

message

public void message(java.lang.String message)
Message sent over the chat system to all clients.

Specified by:
message in interface RiskClientInterface

setTurn

public void setTurn(Player player)
It is player's turn

Specified by:
setTurn in interface RiskClientInterface

showStatus

public void showStatus(java.lang.String status)
Display the supplied string in the clients status line.

Specified by:
showStatus in interface RiskClientInterface

setArmies

public void setArmies(java.lang.String country,
                      int a)
Set the number of armies in a country.

Specified by:
setArmies in interface RiskClientInterface

setOwner

public void setOwner(java.lang.String country,
                     Player player)
Set the owner of the country to the player.

Specified by:
setOwner in interface RiskClientInterface

select

public void select(java.lang.String country)
Set the selection to the country.

Specified by:
select in interface RiskClientInterface

setDice

public void setDice(int[] die)
Supply the current state of the dice to those it interests.

Specified by:
setDice in interface RiskClientInterface

setCards

public void setCards(Card[] cards)
Tell the client the cards that the player has. Clients can connect to the server with two connections if there are two players at that client.

Specified by:
setCards in interface RiskClientInterface