org.dartra.standard
Class StandardMatch

java.lang.Object
  extended byorg.dartra.standard.PersistentObject
      extended byorg.dartra.standard.StandardGame
          extended byorg.dartra.standard.StandardMatch
All Implemented Interfaces:
Game, Match, Persistent
Direct Known Subclasses:
BestOfMatch

public abstract class StandardMatch
extends StandardGame
implements Match

Standard implementation of the Match interface.

A match does not maintain a turn history (or throw history) directly. You will have to look at the games in the match to find the actual turns completed for the match.

Author:
Erwin Vervaet

Constructor Summary
StandardMatch(java.lang.String name, Board board)
           
StandardMatch(java.lang.String name, Board board, Player[] players)
           
 
Method Summary
 void accept(GameVisitor visitor)
          Have given visitor process the data in this game.
protected  void addGame(Game game)
          Add a game to the match.
protected  void addTurn(Turn t)
          This method is not supported for matches.
 Game getCurrentGame()
          Get the currently active game of this match.
 Player getCurrentPlayer()
          Returns the currently active player of the match.
 Turn getCurrentTurn()
          Returns the currently active turn of the match.
 Game getGame(int index)
          Return specified game of this match.
 java.util.Vector getGames()
          Return a list of all games played in this match so far.
 Objective getObjective()
          Get the current objective of the match.
 void registerHit(Zone targetZone, Hit hit)
          Register a hit with the match.
abstract  void start()
          Subclasses should redefine the start method appropriately.
 boolean undoHit()
          Undo the last hit of the match.
 
Methods inherited from class org.dartra.standard.StandardGame
addGameEventListener, getBoard, getEndTime, getFirstPlayer, getGameEventListeners, getName, getPlayer, getPlayers, getPlayerTurn, getPlayerTurnHistory, getProperties, getStartTime, getTurn, getTurnHistory, getWinner, removeGameEventListener, setEndTime, setFirstPlayer, setPlayers, setStartTime, setWinner, toString
 
Methods inherited from class org.dartra.standard.PersistentObject
getId, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.dartra.framework.Game
addGameEventListener, getBoard, getEndTime, getFirstPlayer, getGameEventListeners, getName, getPlayer, getPlayers, getPlayerScore, getPlayerTurn, getPlayerTurnHistory, getStartTime, getTurn, getTurnHistory, getWinner, removeGameEventListener, setFirstPlayer, setWinner
 
Methods inherited from interface org.dartra.framework.Persistent
getId, setId
 

Constructor Detail

StandardMatch

public StandardMatch(java.lang.String name,
                     Board board)

StandardMatch

public StandardMatch(java.lang.String name,
                     Board board,
                     Player[] players)
Method Detail

addGame

protected void addGame(Game game)

Add a game to the match.


getGame

public Game getGame(int index)
Description copied from interface: Match

Return specified game of this match.

Specified by:
getGame in interface Match

getGames

public java.util.Vector getGames()
Description copied from interface: Match

Return a list of all games played in this match so far. The returned list contains Game objects.

Specified by:
getGames in interface Match

getCurrentGame

public Game getCurrentGame()

Get the currently active game of this match. For a standard match, this is the last game of the match, or null if the match does not yet contain any games.

Specified by:
getCurrentGame in interface Match

start

public abstract void start()

Subclasses should redefine the start method appropriately.

Specified by:
start in interface Game
Overrides:
start in class StandardGame

getObjective

public Objective getObjective()

Get the current objective of the match. This is the objective as decided by the currently active game of the match.

Specified by:
getObjective in interface Game

registerHit

public void registerHit(Zone targetZone,
                        Hit hit)

Register a hit with the match. This will register the hit with the currently active game of the match.

Specified by:
registerHit in interface Game

undoHit

public boolean undoHit()

Undo the last hit of the match. This will undo the last throw of the last turn of the last game. If needed, a rollback will be done to the previous turn or even to the previous game.

Specified by:
undoHit in interface Game
Overrides:
undoHit in class StandardGame

getCurrentPlayer

public Player getCurrentPlayer()

Returns the currently active player of the match. This is the current player of the currently active game of the match.

Specified by:
getCurrentPlayer in interface Game
Overrides:
getCurrentPlayer in class StandardGame

getCurrentTurn

public Turn getCurrentTurn()

Returns the currently active turn of the match. This is the current turn of the currently active game of the match.

Specified by:
getCurrentTurn in interface Game
Overrides:
getCurrentTurn in class StandardGame

addTurn

protected void addTurn(Turn t)

This method is not supported for matches.

Overrides:
addTurn in class StandardGame

accept

public void accept(GameVisitor visitor)
Description copied from interface: Game

Have given visitor process the data in this game.

Specified by:
accept in interface Game
Overrides:
accept in class StandardGame