|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.moyoman.framework.Controller
This class and its derived classes controls the execution of commands to the server. This class and its derived classes act as the interface between the Moyoman server and the client api. See for example the org.moyoman.comm.client.DirectCommandExecutor class.
There is one Controller object for each game that is being played by the server. Note that in a computer - computer game, there would be one Controller object for each player.
There are also static methods in this class, such as for file management, or other tasks not related to a particular game.
Field Summary | |
private Color |
color
The color of the player in this game. |
private static HashMap |
controllers
The key is the GameId object, and the value is the Controller object. |
protected GameRecord |
gr
The game record of the game. |
private Handicap |
handicap
The handicap for this game. |
protected GameId |
id
The id of the game. |
private float |
komi
The komi for this game. |
private Mode |
mode
The mode for the player in this game. |
protected static Persister |
persister
The persister is used for loading/saving games. |
private static HashMap |
properties
The key is the GameId object, and the value is a Properties object. |
private Rules |
rules
The rules for this game. |
protected Scheduler |
scheduler
The scheduler for this game. |
Constructor Summary | |
protected |
Controller(Color color,
Handicap handicap,
Mode m)
Create a new Controller object. |
protected |
Controller(Color color,
Handicap handicap,
Mode mode,
Rules rules,
float komi)
Create a new Controller object. |
Method Summary | |
static void |
deleteGame(String name)
Delete the specified game from permanent storage. |
static void |
endGame(String name)
Delete the game from temporary storage. |
static boolean |
gameExists(GameId gid)
Determine if the given game exists. |
Color |
getColor()
Get the color of this player. |
protected static Controller |
getController(GameId id)
|
GameRecord |
getGameRecord()
Get the game record for the specified game. |
Handicap |
getHandicap()
Get the handicap of the game. |
GameId |
getId()
Get the game id for this Controller. |
float |
getKomi()
Get the komi for this game. |
Stone |
getLastMoveKo()
|
Mode |
getMode()
Get the mode for this player. |
static Mode |
getMode(GameId gid)
Get the mode for a particular game. |
short |
getMoveNumber()
Get the number of the next move in this game. |
protected static Persister |
getPersister()
Get the Persister object. |
Properties |
getProperties()
Get the properties for the specified game. |
Rules |
getRules()
Get the rules for this game. |
static Rules |
getRules(GameId gid)
Get the rules for a particular game. |
Stone[] |
getSuicideMoves()
|
Stone[] |
getSuperKoMoves()
|
static String[] |
listActiveGames()
Get a list of all of the active games on the server. |
static String[] |
listSavedGames()
Get a list of all of the games in permanent storage on the server. |
static Controller[] |
loadGame(String name)
Make a game in permanent storage on the server active. |
private MoveDescriptor |
makeMove(Move move)
Update the specified game with this move from the client. |
MoveDescriptor |
makeMove(Stone stone)
Update the specified game with this move from the client. |
static void |
onExit()
|
MoveDescriptor |
pass()
The client passes in the specified game. |
void |
resignGame()
The client is resigning the specified game. |
static Controller[] |
resumeActiveGame()
Continue play from the most recent temporary game stored. |
static Controller |
resumeActiveGame(GameId id)
Continue play from the temporary game stored. |
static void |
saveGame(String name,
GameId black,
GameId white)
Save the specified game to permanent storage. |
void |
setProperties(Properties p)
Set the properties for the specified game. |
private void |
setVars(Color color,
Handicap handicap,
Mode mode,
Rules rules,
float komi,
GameId gid)
Set the variables for the Controller object on construction. |
void |
takeBackMove()
Take back a move in the specified game. |
static void |
writeLastGameInformation(String blackId,
String whiteId)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected GameId id
protected GameRecord gr
protected Scheduler scheduler
protected static Persister persister
private static HashMap controllers
private static HashMap properties
private Color color
private Handicap handicap
private Mode mode
private Rules rules
private float komi
Constructor Detail |
protected Controller(Color color, Handicap handicap, Mode mode, Rules rules, float komi) throws InternalErrorException
color
- The color of the player using the server to play this game.handicap
- The handicap of this game.mode
- The mode used by the player using the server to play this game.rules
- The rules for this game.komi
- The komi for this game.
InternalErrorException
- Thrown if the operation fails for any reason.protected Controller(Color color, Handicap handicap, Mode m) throws InternalErrorException
color
- The color of the player using the server to play this game.handicap
- The handicap of this game.
InternalErrorException
- Thrown if the operation fails for any reason.Method Detail |
private void setVars(Color color, Handicap handicap, Mode mode, Rules rules, float komi, GameId gid) throws InternalErrorException
color
- The color of the player using the server to play this game.handicap
- The handicap of this game.mode
- The mode used by the player using the server to play this game.rules
- The rules for this game.komi
- The komi for this game.
InternalErrorException
- Thrown if the operation fails for any reason.protected static Persister getPersister()
public static boolean gameExists(GameId gid)
gid
- The game id being checked.
public static void deleteGame(String name) throws NoSuchDataException, InternalErrorException
name
- The game to be deleted.
NoSuchDataException
- Thrown if the id does
not correspond to a stored game.
InternalErrorException
- Thrown if the operation
fails for any reason.public static void endGame(String name) throws NoSuchDataException, InternalErrorException
name
- The game to be deleted.
NoSuchDataException
- Thrown if the id does
not correspond to a stored game.
InternalErrorException
- Thrown if the operation
fails for any reason.public GameRecord getGameRecord()
public GameId getId()
public void setProperties(Properties p)
p
- The properties to be set.public Stone getLastMoveKo()
public Stone[] getSuicideMoves()
public Stone[] getSuperKoMoves()
public Properties getProperties()
public static String[] listActiveGames() throws InternalErrorException
InternalErrorException
- Thrown if the operation fails for any reason.public static String[] listSavedGames() throws InternalErrorException
InternalErrorException
- Thrown if the operation fails for any reason.protected static Controller getController(GameId id)
public static Controller[] loadGame(String name) throws NoSuchDataException, InternalErrorException
name
- The name of the game.
NoSuchDataException
- Thrown if the game id cannot be found.
InternalErrorException
- Thrown if the operation fails for any reason.public MoveDescriptor makeMove(Stone stone) throws IllegalMoveException, InternalErrorException
stone
- The move that was made.
IllegalMoveException
- Thrown if the move to be made is not legal.
InternalErrorException
- Thrown if the operation fails for any reason.private MoveDescriptor makeMove(Move move) throws IllegalMoveException, InternalErrorException
move
- The move to be made.
IllegalMoveException
- Thrown if the move to be made is not legal.
InternalErrorException
- Thrown if the operation fails for any reason.public MoveDescriptor pass() throws InternalErrorException
InternalErrorException
- Thrown if the operation fails for any reason.public void resignGame() throws InternalErrorException
InternalErrorException
- Thrown if the operation fails for any reason.public static Controller resumeActiveGame(GameId id) throws NoSuchDataException, InternalErrorException
id
- The id of the game.
NoSuchDataException
- Thrown if the operation fails for any reason.
InternalErrorException
public static Controller[] resumeActiveGame() throws NoSuchDataException, InternalErrorException
InternalErrorException
- Thrown if the operation fails for any reason.
NoSuchDataException
public static void saveGame(String name, GameId black, GameId white) throws DataAlreadyExistsException, InternalErrorException
DataAlreadyExistsException
- Thrown if the new id is already in use.
InternalErrorException
- Thrown if the operation fails for any reason.public void takeBackMove() throws NoSuchDataException, InternalErrorException
NoSuchDataException
- Thrown if the move history is not stored.
InternalErrorException
- Thrown if the operation fails for any reason.public static void writeLastGameInformation(String blackId, String whiteId)
public short getMoveNumber() throws InternalErrorException
InternalErrorException
- Thrown if the operation fails for any reason.public Color getColor()
public Handicap getHandicap()
public Mode getMode()
public Rules getRules()
public float getKomi()
public static Mode getMode(GameId gid) throws NoSuchDataException
gid
- The game id to get the mode for.
NoSuchDataException
- Thrown if the game is not active.public static Rules getRules(GameId gid) throws NoSuchDataException
gid
- The game id to get the mode for.
NoSuchDataException
- Thrown if the game is not active.public static void onExit()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |