|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.moyoman.comm.client.PlayerManager
This class manages the play of a single game of Go
| Field Summary | |
private Player |
blackPlayer
The player playing black. |
private CommandExecutor |
ce
|
private boolean |
continueFlag
If singleStepFlag is true, then play pauses until this variable is set to true. |
private boolean |
singleStepFlag
If true, then play pauses after each move. |
private Color |
toMove
The color of the player to move next. |
private Player |
whitePlayer
The player playing white. |
| Constructor Summary | |
PlayerManager(Player black,
Player white)
Create the PlayerManager object. |
|
PlayerManager(Player black,
Player white,
GameRecord gr)
Create a PlayerManager object to continue play for the specified game. |
|
| Method Summary | |
private boolean |
blackMove()
Get a move from the black player, and send it to the white player. |
Player |
getBlackPlayer()
|
GameRecord |
getGameRecord()
Get the game record for this game. |
MoyomanPlayer[] |
getMoyomanPlayers()
Return an array of MoyomanPlayer objects. |
MoveDescriptor |
getSuggestedMove()
|
Player |
getWhitePlayer()
|
private Color |
initializeBoard(GameRecord gr)
Initialize the board for the two players. |
boolean |
isSingleStep()
Determine whether the single step flag is set. |
private void |
pause()
Pause the game until receiving a signal to continue. |
void |
play()
Play a game of Go, using the two Player objects. |
protected Color |
playPrerecordedMoves(GameRecord gr,
boolean blackFlag,
boolean whiteFlag)
Play out a game record of prerecorded moves. |
void |
setSingleStepFlag(boolean flag)
Set the single step flag. |
void |
singleStep()
Cause one more move to be made. |
boolean |
takeBackMove()
Return to an earlier state in the game. |
private boolean |
whiteMove()
Get a move from the white player, and send it to the black player. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private Player blackPlayer
private Player whitePlayer
private Color toMove
private boolean singleStepFlag
private boolean continueFlag
private CommandExecutor ce
| Constructor Detail |
public PlayerManager(Player black,
Player white)
throws InternalErrorException
black - The Player which is playing black.white - The Player which is playing white.
public PlayerManager(Player black,
Player white,
GameRecord gr)
throws InternalErrorException
black - - The black playerwhite - - The white playergr - - The game record of the position to resume from.
InternalErrorException - - Thrown if an error occurs in
starting the game from the position in the game record.| Method Detail |
public Player getBlackPlayer()
public Player getWhitePlayer()
public void singleStep()
public void setSingleStepFlag(boolean flag)
flag - If true, then single step through the game.public boolean isSingleStep()
public void play()
throws InternalErrorException
InternalErrorException - Thrown if the game cannot be
played for any reason, such as differing initial
board for the two players.
public boolean takeBackMove()
throws InconsistentStateException,
InternalErrorException
InconsistentStateException - - Thrown if the
moves are taken back for one player but not the other.
There should be rollback functionality to take care
of this case.
InternalErrorException - - Thrown if an error occurs for any reason.
private boolean blackMove()
throws InternalErrorException
InternalErrorException - - Thrown is an error occurs for any reason.
private boolean whiteMove()
throws InternalErrorException
InternalErrorException - - Thrown is an error occurs for any reason.private void pause()
private Color initializeBoard(GameRecord gr)
throws InternalErrorException
InternalErrorException - Thrown if the game
cannot be played for any reason, such as differing
initial boards for the two players.
protected Color playPrerecordedMoves(GameRecord gr,
boolean blackFlag,
boolean whiteFlag)
throws InternalErrorException
gr - The game record of the moves to be played out.blackFlag - Only make calls on black player if this is false.whiteFlag - Only make calls on white player if this is false.
InternalErrorException - Thrown if the operation fails for any reason.public MoyomanPlayer[] getMoyomanPlayers()
public GameRecord getGameRecord()
throws InternalErrorException
InternalErrorException - Thrown if the game record cannot be
retrieved for any reason.
public MoveDescriptor getSuggestedMove()
throws RuntimeException
RuntimeException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||