de.tabacha.cgo.tournament
Class TournamentGame

java.lang.Object
  extended byde.tabacha.cgo.tournament.TournamentGame
All Implemented Interfaces:
Constants, Game

public class TournamentGame
extends java.lang.Object
implements Constants, Game

Represents one game of conwaygo: two players and a board.
$Id: TournamentGame.java,v 1.9 2004/12/23 21:42:44 mk Exp $

Version:
$Revision: 1.9 $
Threadsafe?
false

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
TournamentGame(Engine playerUp, Engine playerDown)
          Constructor.
 
Method Summary
 void addGameListener(GameListener listener)
          Adds a GameListener that will be notified of game events.
 int averageTime(boolean direction)
           
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(Move move, boolean direction)
          Method to support listener events.
protected  void firePlayerChanged(boolean newPlayerDirection)
          Method to support listener events.
 Board getBoard()
          Returns the board with the game position.
 int getMoveCount()
          Returns the number of moves played in the game.
 Engine getPlayer(boolean direction)
          Returns the routine that makes the moves in the specified direction.
 Engine getPlayerToMove()
          Returns the player who has to move now.
 boolean getWinner()
          Returns the playing direction of the winner of the game.
 void play()
          Starts playing 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.
 long usedTime(boolean direction)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TournamentGame

public TournamentGame(Engine playerUp,
                      Engine playerDown)
Constructor.

Method Detail

getPlayer

public Engine getPlayer(boolean direction)
Description copied from interface: Game
Returns the routine that makes the moves in the specified direction.

Specified by:
getPlayer in interface Game

getPlayerToMove

public Engine getPlayerToMove()
Returns the player who has to move now.

Specified by:
getPlayerToMove in interface Game

setPlayer

public void setPlayer(boolean direction,
                      Engine player)
Sets the routine that makes the moves in the specified direction. Change will not take place for the current move.

Specified by:
setPlayer in interface Game

getBoard

public Board getBoard()
Returns the board with the game position. Never returns zero.

Specified by:
getBoard in interface Game

getWinner

public boolean getWinner()
Returns the playing direction of the winner of the game. No warning if the game is still played!.


getMoveCount

public int getMoveCount()
Returns the number of moves played in the game.


addGameListener

public void addGameListener(GameListener listener)
Description copied from interface: Game
Adds a GameListener that will be notified of game events.

Specified by:
addGameListener in interface Game

removeGameListener

public void removeGameListener(GameListener listener)
Description copied from interface: Game
Removes a GameListener. Nothing will happen if the listener has not been registered.

Specified by:
removeGameListener in interface Game

fireGameStarted

protected void fireGameStarted()
Method to support listener events.


fireGameAborted

protected void fireGameAborted(boolean direction,
                               Move move,
                               java.lang.String message)
Method to support listener events.


fireGameEnded

protected void fireGameEnded(boolean winnerDirection)
Method to support listener events.


fireHasMoved

protected void fireHasMoved(Move move,
                            boolean direction)
Method to support listener events.


firePlayerChanged

protected void firePlayerChanged(boolean newPlayerDirection)
Method to support listener events.


play

public void play()
          throws java.lang.IllegalStateException
Description copied from interface: Game
Starts playing the game. Listeners are informed of game events, so no return values are necessary.

Specified by:
play in interface Game
Throws:
java.lang.IllegalStateException - If a player is null or the game is already running.

averageTime

public int averageTime(boolean direction)

usedTime

public long usedTime(boolean direction)