|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectde.tabacha.cgo.DefaultGame
Represents one game of conwaygo: two players and a board.
$Id: DefaultGame.java,v 1.16 2004/12/23 21:42:43 mk Exp $
| Field Summary |
| Fields inherited from interface de.tabacha.cgo.Constants |
BALL, COL_COUNT, DCOL, DOWN, DROW, E, EMPTY, FIRST_DIRECTION, KICK_OFF_FIELD, LAST_DIRECTION, N, NE, NW, OPPOSITE, PIECE, ROW_COUNT, S, SE, SW, UP, UPSIDEDOWN, W |
| Constructor Summary | |
DefaultGame(Engine playerUp,
Engine playerDown)
Constructor. |
|
| Method Summary | |
void |
abort()
Interrupts the game. |
void |
addGameListener(GameListener listener)
Adds a GameListener that will be notified of game events. |
void |
destroy()
Kills the threads. |
protected void |
fireGameAborted(boolean direction,
Move move,
java.lang.String message)
Method to support listener events. |
protected void |
fireGameEnded(boolean winnerDirection)
Method to support listener events. |
protected void |
fireGameStarted()
Method to support listener events. |
protected void |
fireHasMoved(boolean direction,
Move move)
Method to support listener events. |
protected void |
firePlayerChanged(boolean newPlayerDirection)
Method to support listener events. |
Board |
getBoard()
Returns the board with the game position. |
Engine |
getPlayer(boolean direction)
Returns the engine that plays in the specified direction. |
Engine |
getPlayerToMove()
Returns the player who has to move now. |
boolean |
isAlive()
Returns true if a game is running. |
void |
play()
Starts the game. |
void |
removeGameListener(GameListener listener)
Removes a GameListener. |
void |
setPlayer(boolean direction,
Engine player)
Sets the routine that makes the moves in the specified direction. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public DefaultGame(Engine playerUp,
Engine playerDown)
| Method Detail |
public Engine getPlayer(boolean direction)
getPlayer in interface Gamepublic Engine getPlayerToMove()
getPlayerToMove in interface Game
public void setPlayer(boolean direction,
Engine player)
setPlayer in interface Gamepublic Board getBoard()
getBoard in interface Gamepublic void addGameListener(GameListener listener)
Game
addGameListener in interface Gamepublic void removeGameListener(GameListener listener)
Game
removeGameListener in interface Gameprotected void fireGameStarted()
protected void fireGameAborted(boolean direction,
Move move,
java.lang.String message)
protected void fireGameEnded(boolean winnerDirection)
protected void fireHasMoved(boolean direction,
Move move)
protected void firePlayerChanged(boolean newPlayerDirection)
public void play()
throws java.lang.IllegalStateException
play in interface BackgroundGamejava.lang.IllegalStateException - If a player is null or the game is already running.public boolean isAlive()
isAlive in interface BackgroundGamepublic void abort()
abort in interface BackgroundGamepublic void destroy()
In a normal application, the threads will run forever - as long as the VM. This is intended to save the overhead of initializing and starting new threads for each new game.
But when the applet is destroyed, it has to free system resources even if the VM works on.
destroy in interface BackgroundGame
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||