|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.dartra.standard.PersistentObject
org.dartra.standard.StandardGame
org.dartra.standard.StandardMatch
org.dartra.standard.BestOfMatch
A match which has as winner the player that won more than half of the number of games played. The 'best-of' (the maximum number of games played) needs to be uneven.
A subclass of this class implementing a standard "best-of" match will simply have to override
the createNewGame()
method.
Constructor Summary | |
BestOfMatch(java.lang.String name,
Board board,
int bestOf,
boolean determineFirstPlayer)
|
|
BestOfMatch(java.lang.String name,
Board board,
Player[] players,
int bestOf,
boolean determineFirstPlayer)
|
|
BestOfMatch(java.lang.String name,
Board board,
Player[] players,
StringProperties props)
|
|
BestOfMatch(java.lang.String name,
Board board,
StringProperties props)
|
Method Summary | |
protected void |
checkMatchWinner()
Checks if this match has a winner: goes through the games that have been played, and checks if one player has won more than half of the games of this match. |
protected int |
countGamesWon(Player player)
Counts the number of games the given player has won so far in this match. |
protected abstract Game |
createNewGame()
Subclasses should define this method appropriately. |
int |
getBestOf()
Returns the best-of (the maximum number of games) for this match. |
protected Player[] |
getPlayerArray()
Returns the array with the players of this match. |
Score |
getPlayerScore(Player player)
Returns the player score for this match, this is the number of games the given player has won in this match. |
StringProperties |
getProperties()
Subclasses should implement this to properly return their game specific properties (for instance the "start score" for an x01 game). |
void |
start()
Starts the best-of match. |
protected void |
startNewGame()
Starts a new game in this match. |
java.lang.String |
toString()
|
Methods inherited from class org.dartra.standard.StandardMatch |
accept, addGame, addTurn, getCurrentGame, getCurrentPlayer, getCurrentTurn, getGame, getGames, getObjective, registerHit, undoHit |
Methods inherited from class org.dartra.standard.StandardGame |
addGameEventListener, getBoard, getEndTime, getFirstPlayer, getGameEventListeners, getName, getPlayer, getPlayers, getPlayerTurn, getPlayerTurnHistory, getStartTime, getTurn, getTurnHistory, getWinner, removeGameEventListener, setEndTime, setFirstPlayer, setPlayers, setStartTime, setWinner |
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, getPlayerTurn, getPlayerTurnHistory, getStartTime, getTurn, getTurnHistory, getWinner, removeGameEventListener, setFirstPlayer, setWinner |
Methods inherited from interface org.dartra.framework.Persistent |
getId, setId |
Constructor Detail |
public BestOfMatch(java.lang.String name, Board board, StringProperties props)
public BestOfMatch(java.lang.String name, Board board, int bestOf, boolean determineFirstPlayer)
public BestOfMatch(java.lang.String name, Board board, Player[] players, StringProperties props)
public BestOfMatch(java.lang.String name, Board board, Player[] players, int bestOf, boolean determineFirstPlayer)
Method Detail |
protected abstract Game createNewGame()
Subclasses should define this method appropriately.
public void start()
Starts the best-of match. Sets the starting time, and starts a closest-to-zone game first, if required to do so.
start
in interface Game
start
in class StandardMatch
protected void startNewGame()
Starts a new game in this match.
public Score getPlayerScore(Player player)
Returns the player score for this match, this is the number of games the given player has won in this match.
protected void checkMatchWinner()
Checks if this match has a winner: goes through the games that have been played, and checks if one player has won more than half of the games of this match.
If a match winner is found, it will be set using setWinner()
.
protected int countGamesWon(Player player)
Counts the number of games the given player has won so far in this match.
protected Player[] getPlayerArray()
Returns the array with the players of this match.
public int getBestOf()
Returns the best-of (the maximum number of games) for this match.
public java.lang.String toString()
toString
in class StandardGame
public StringProperties getProperties()
StandardGame
Subclasses should implement this to properly return their game specific properties (for instance the "start score" for an x01 game).
It is legal to return null if there are no game specific properties.
getProperties
in class StandardGame
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |