|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.org.redfelineninja.risk.robot.GameState
This class stores all information about the game state for interagation by the robot. It monitors network messages in order to maintain its own state without any invention from a robot's programmer. From this network activity this class is also responsible for calling the robots makeMove method. A robots author should only use the interogation methods. Those that reflect game state, not that alter game state. Currently GameState allows programmers to access all the methods in the RiskClientInterface. This will be changed for the next version, they will be removed and put somewhere private. Untill then a robot author who calls these funtions is likely to find their robot doing some very strange things.
Field Summary | |
static int |
ATTACK
Mode constant, a friendly country has been selected, we are expecting attack something. |
static int |
FORTIFY
Mode constant, waiting for a country to fortify. |
static int |
FORTIFY_PLACEMENT
Mode constant, placement limieted by the rules of fortification. |
static int |
INIT_PLACEMENT
Mode constant, placement of initial armies. |
static int |
INIT_SELECTION
Mode constant, initial selection of countries. |
static int |
LIMITED_PLACEMENT
Mode constant, placement restricted after a country has been defeated. |
static int |
NULL
Mode constant, game is in null state. |
static int |
PLACEMENT
Mode constant, unrestricted placement of armies from the pool. |
static int |
SELECTION
Mode constant, No country is selected. |
Constructor Summary | |
GameState(java.io.File f,
Robot r)
Create a new GameState. |
Method Summary | |
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. |
int |
getBoardSize()
Get the size of the board. |
Move |
getContinentWeights()
Get the percentage ownership of each continent. |
uk.org.redfelineninja.risk.robot.Country |
getCountry(int i)
Get the requested country. |
uk.org.redfelineninja.risk.robot.Country |
getCountry(java.lang.String name)
Get the requested country. |
Move |
getLegalMoves()
Get the Moves available to the robot. |
int |
getMode()
Get the current mode. |
Move |
getRelativeStrength()
Get the relative strength of each country on the board. |
float |
getRelativeStrength(uk.org.redfelineninja.risk.robot.Country c)
Get the relative strength of a single country. |
uk.org.redfelineninja.risk.robot.Country |
getSelection()
Get the currently selected country. |
Move |
getStrength()
Get the absolute strength of each country on the board. |
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. |
boolean |
myTurn()
Test whether the robot associated with this GameState is the active player. |
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)
Select the supplied 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 |
setServer(RiskServerInterface s)
Set the server that this game state is attached to. |
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.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int NULL
public static final int INIT_SELECTION
public static final int INIT_PLACEMENT
public static final int PLACEMENT
public static final int ATTACK
public static final int LIMITED_PLACEMENT
public static final int FORTIFY_PLACEMENT
public static final int FORTIFY
public static final int SELECTION
Constructor Detail |
public GameState(java.io.File f, Robot r) throws java.io.FileNotFoundException
Method Detail |
public int getMode()
public boolean myTurn()
public int getBoardSize()
public final uk.org.redfelineninja.risk.robot.Country getCountry(int i)
i
- index of the country
public final uk.org.redfelineninja.risk.robot.Country getCountry(java.lang.String name)
name
- the name of the country to be fetched
public final uk.org.redfelineninja.risk.robot.Country getSelection()
public final Move getStrength()
Absolute strength is the number of armies each contry contains.
public final Move getRelativeStrength()
Relative strength is the absolute strength of a country and its friendly neighbours minus the absolute strength of all hostile neighbours.
public final float getRelativeStrength(uk.org.redfelineninja.risk.robot.Country c)
Relative strength is the absolute strength of a country and its friendly neighbours minus the absolute strength of all hostile neighbours.
public final Move getContinentWeights()
This does not work and exists only as a test stub. Do not use this unless you are developing the Risk Arena.
public Move getLegalMoves()
This method is used internally to ensure that the robot only makes legal moves. It can be used by advanced robots to prevent wasting time analysing illegal moves.
public void setServer(RiskServerInterface s)
Robot authurs should not normally call this method.
public void newPlayer(Player player)
Robot authurs should not normally call this method.
newPlayer
in interface RiskClientInterface
public void newSpectator(Player player)
Robot authurs should not normally call this method.
newSpectator
in interface RiskClientInterface
public void lostPlayer(Player player)
Robot authurs should not normally call this method.
lostPlayer
in interface RiskClientInterface
public void newGame(Player[] players)
Robot authurs should not normally call this method.
newGame
in interface RiskClientInterface
public void gameOver(Player victor)
Robot authurs should not normally call this method.
gameOver
in interface RiskClientInterface
public void gameOver(Player player, java.lang.String reason)
Robot authurs should not normally call this method.
gameOver
in interface RiskClientInterface
public void message(java.lang.String message)
Robot authurs should not normally call this method.
message
in interface RiskClientInterface
public void setTurn(Player player)
Robot authurs should not normally call this method.
setTurn
in interface RiskClientInterface
public void showStatus(java.lang.String status)
Robot authurs should not normally call this method.
showStatus
in interface RiskClientInterface
public void setArmies(java.lang.String country, int a)
Robot authurs should not normally call this method.
setArmies
in interface RiskClientInterface
public void setOwner(java.lang.String country, Player player)
Robot authurs should not normally call this method.
setOwner
in interface RiskClientInterface
public void select(java.lang.String country)
Robot authurs should not normally call this method.
select
in interface RiskClientInterface
public void setDice(int[] die)
Robot authurs should not normally call this method.
setDice
in interface RiskClientInterface
public void setCards(Card[] cards)
Robot authurs should not normally call this method.
setCards
in interface RiskClientInterface
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |