|
||||||||||
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
Standard base implementation of the Game interface.
Constructor Summary | |
StandardGame(java.lang.String name,
Board board)
|
|
StandardGame(java.lang.String name,
Board board,
Player[] players)
|
Method Summary | |
void |
accept(GameVisitor visitor)
Have given visitor process the data in this game. |
void |
addGameEventListener(GameEventListener gel)
Add given game event listener to the list of listeners that will be notified when a game event occurs. |
protected void |
addTurn(Turn t)
Add a turn to the game. |
Board |
getBoard()
Returns the board the game is played on. |
Player |
getCurrentPlayer()
Return the currently active player. |
Turn |
getCurrentTurn()
Returns the currently active turn of the game. |
long |
getEndTime()
Returns the time at which the game ended, or -1 if it did not yet end. |
Player |
getFirstPlayer()
Returns the player that will be the first to throw. |
java.util.Vector |
getGameEventListeners()
Get the collection of game event listeners maintained by this object. |
java.lang.String |
getName()
Return the name of this game. |
Player |
getPlayer(int index)
Get a particular player participating in the game. |
java.util.Vector |
getPlayers()
Returns the list of players participating in the game. |
Turn |
getPlayerTurn(Player player,
int index)
Get the specified turn for given player. |
java.util.Vector |
getPlayerTurnHistory(Player player)
Returns a list representing the turn history of given player in this game. |
abstract StringProperties |
getProperties()
Subclasses should implement this to properly return their game specific properties (for instance the "start score" for an x01 game). |
long |
getStartTime()
Returns the time at which the game started, or -1 if it did not yet start. |
Turn |
getTurn(int index)
Get specified turn of the game. |
java.util.Vector |
getTurnHistory()
Returns a list containing all turns of the game so far. |
Player |
getWinner()
Returns the player that won the game, or null if no winner has been established yet. |
void |
removeGameEventListener(GameEventListener gel)
Remove given game event listener from the list of listeners maintained by this object. |
protected void |
setEndTime(long ts)
|
void |
setFirstPlayer(Player player)
Set the player that will be the first to throw. |
protected void |
setPlayers(Player[] players)
Set the players of the game. |
protected void |
setStartTime(long ts)
|
void |
setWinner(Player player)
Set the winner of the game. |
void |
start()
Start the game. |
java.lang.String |
toString()
|
boolean |
undoHit()
Undo the effect of the last hit. |
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 |
getObjective, getPlayerScore, registerHit |
Methods inherited from interface org.dartra.framework.Persistent |
getId, setId |
Constructor Detail |
public StandardGame(java.lang.String name, Board board)
public StandardGame(java.lang.String name, Board board, Player[] players)
Method Detail |
public Board getBoard()
Game
Returns the board the game is played on.
getBoard
in interface Game
protected void setPlayers(Player[] players)
Set the players of the game. Use this method if you did not pass the players to the constructor.
Players must be set before starting the game and can only be set once.
public java.util.Vector getPlayers()
Game
Returns the list of players participating in the game. The returned list contains Player objects.
getPlayers
in interface Game
public Player getPlayer(int index)
Game
Get a particular player participating in the game.
getPlayer
in interface Game
public void setFirstPlayer(Player player)
Game
Set the player that will be the first to throw.
setFirstPlayer
in interface Game
public Player getFirstPlayer()
Game
Returns the player that will be the first to throw.
getFirstPlayer
in interface Game
public void setWinner(Player player)
Set the winner of the game. A standard game ends when the winner is set.
setWinner
in interface Game
public Player getWinner()
Game
Returns the player that won the game, or null if no winner has been established yet.
getWinner
in interface Game
protected void setStartTime(long ts)
public long getStartTime()
Game
Returns the time at which the game started, or -1 if it did not yet start.
getStartTime
in interface Game
protected void setEndTime(long ts)
public long getEndTime()
Game
Returns the time at which the game ended, or -1 if it did not yet end.
getEndTime
in interface Game
public java.lang.String getName()
Game
Return the name of this game.
getName
in interface Game
public void start()
Start the game. For a standard game this means that a new turn is created for the current player (normally the first player, as indicated by the getFirstPlayer() method).
start
in interface Game
public boolean undoHit()
Undo the effect of the last hit. For a standard game, this means that the last throw of the last turn is removed. If the last turn does not yet contain a throw, the turn history is rolled back to the previous turn, and the last throw of that turn is removed.
undoHit
in interface Game
public Player getCurrentPlayer()
Return the currently active player. For a standard game this is the player of the current turn, or if no turn has been started yet, the first player of the game, as returned by the getFirstPlayer() method.
getCurrentPlayer
in interface Game
public Turn getCurrentTurn()
Returns the currently active turn of the game. For a standard game this is the last (most recent) turn.
getCurrentTurn
in interface Game
public Turn getPlayerTurn(Player player, int index)
Game
Get the specified turn for given player.
getPlayerTurn
in interface Game
public java.util.Vector getPlayerTurnHistory(Player player)
Game
Returns a list representing the turn history of given player in this game. The first element in the list is the first turn, the last element the most recent turn.
The returned list contains Turn objects.
getPlayerTurnHistory
in interface Game
protected void addTurn(Turn t)
Add a turn to the game.
public Turn getTurn(int index)
Game
Get specified turn of the game.
getTurn
in interface Game
public java.util.Vector getTurnHistory()
Game
Returns a list containing all turns of the game so far. The first element in the list is the first turn, the last element the most recent turn.
The returned list contains Turn objects.
getTurnHistory
in interface Game
public void addGameEventListener(GameEventListener gel)
Game
Add given game event listener to the list of listeners that will be notified when a game event occurs.
addGameEventListener
in interface Game
public void removeGameEventListener(GameEventListener gel)
Game
Remove given game event listener from the list of listeners maintained by this object.
removeGameEventListener
in interface Game
public java.util.Vector getGameEventListeners()
Game
Get the collection of game event listeners maintained by this object. The returned collection contains GameEventListener objectgs.
getGameEventListeners
in interface Game
public void accept(GameVisitor visitor)
Game
Have given visitor process the data in this game.
accept
in interface Game
public abstract StringProperties getProperties()
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.
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |