uk.org.redfelineninja.risk.server
Class RiskEngine

java.lang.Object
  |
  +--uk.org.redfelineninja.risk.server.RiskEngine

public class RiskEngine
extends java.lang.Object

This class is the heart of the Risk system. This is a very large class that provides all the control and state broadcast for the Risk Arena. It is suitable for use in all servers and has been been extensively tested in use. There has been no boundary testing however so the odd bug may still remain.


Field Summary
static int ATTACK
           
static int FORTIFY
           
static int FORTIFY_PLACEMENT
           
static int GAME_OVER
           
static int ILLEGAL_ACTION
           
static int INIT_PLACEMENT
           
static int INIT_SELECTION
           
static int LIMITED_PLACEMENT
           
static int NO_ARMIES
           
static int NO_SUCH_COUNTRY
           
static int NOT_ADJACENT
           
static int NOT_ALLOWED
           
static int NOT_CURRENT_PLAYER
           
static int NOT_OWNER
           
static int OK
           
static int PLACEMENT
           
 
Constructor Summary
RiskEngine(Player[] p, Adjacency a, java.util.Hashtable ct, RiskClientWriter clnt)
          Create a new risk engine.
 
Method Summary
 int cheat(Player p)
          Player p wants to cheat.
 int click(java.lang.String c, Player p)
          This method is called to inform the engine that a the player, p, has clicked on country.
 int finish(Player p)
          Player p wants to finish their turn.
 void forceNextTurn()
          Force the turn to move to the next player.
 int fortify(Player p)
          Player p wants to fortify.
 Player getActivePlayer()
          Returns the player whose turn it is.
 int getMode()
          Returns the current mode.
 boolean liveGame()
           
 void randomise()
          Assign the players their countries randomly.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INIT_SELECTION

public static final int INIT_SELECTION
See Also:
Constant Field Values

INIT_PLACEMENT

public static final int INIT_PLACEMENT
See Also:
Constant Field Values

PLACEMENT

public static final int PLACEMENT
See Also:
Constant Field Values

ATTACK

public static final int ATTACK
See Also:
Constant Field Values

LIMITED_PLACEMENT

public static final int LIMITED_PLACEMENT
See Also:
Constant Field Values

FORTIFY_PLACEMENT

public static final int FORTIFY_PLACEMENT
See Also:
Constant Field Values

FORTIFY

public static final int FORTIFY
See Also:
Constant Field Values

OK

public static final int OK
See Also:
Constant Field Values

NO_ARMIES

public static final int NO_ARMIES
See Also:
Constant Field Values

NOT_CURRENT_PLAYER

public static final int NOT_CURRENT_PLAYER
See Also:
Constant Field Values

NOT_ADJACENT

public static final int NOT_ADJACENT
See Also:
Constant Field Values

NOT_OWNER

public static final int NOT_OWNER
See Also:
Constant Field Values

ILLEGAL_ACTION

public static final int ILLEGAL_ACTION
See Also:
Constant Field Values

NO_SUCH_COUNTRY

public static final int NO_SUCH_COUNTRY
See Also:
Constant Field Values

NOT_ALLOWED

public static final int NOT_ALLOWED
See Also:
Constant Field Values

GAME_OVER

public static final int GAME_OVER
See Also:
Constant Field Values
Constructor Detail

RiskEngine

public RiskEngine(Player[] p,
                  Adjacency a,
                  java.util.Hashtable ct,
                  RiskClientWriter clnt)
Create a new risk engine.

Parameters:
p - array of player to play this game
a - adjacency matrix describing the board
ct - hashtable (String -> Continent)
clnt - the network interface for this engine
Method Detail

randomise

public void randomise()
Assign the players their countries randomly.


getActivePlayer

public Player getActivePlayer()
Returns the player whose turn it is.


liveGame

public boolean liveGame()

getMode

public int getMode()
Returns the current mode.


click

public int click(java.lang.String c,
                 Player p)
This method is called to inform the engine that a the player, p, has clicked on country.


forceNextTurn

public void forceNextTurn()
Force the turn to move to the next player. This should only ever be called if a player has resigned from the game.


fortify

public int fortify(Player p)
Player p wants to fortify.


finish

public int finish(Player p)
Player p wants to finish their turn.


cheat

public int cheat(Player p)
Player p wants to cheat. We can accomadate this by assigned all countries except on to our cheater.

Parameters:
p -
Returns:
int