|
||||||||||
| 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()
GameReturns the board the game is played on.
getBoard in interface Gameprotected 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()
GameReturns the list of players participating in the game. The returned list contains Player objects.
getPlayers in interface Gamepublic Player getPlayer(int index)
GameGet a particular player participating in the game.
getPlayer in interface Gamepublic void setFirstPlayer(Player player)
GameSet the player that will be the first to throw.
setFirstPlayer in interface Gamepublic Player getFirstPlayer()
GameReturns the player that will be the first to throw.
getFirstPlayer in interface Gamepublic void setWinner(Player player)
Set the winner of the game. A standard game ends when the winner is set.
setWinner in interface Gamepublic Player getWinner()
GameReturns the player that won the game, or null if no winner has been established yet.
getWinner in interface Gameprotected void setStartTime(long ts)
public long getStartTime()
GameReturns the time at which the game started, or -1 if it did not yet start.
getStartTime in interface Gameprotected void setEndTime(long ts)
public long getEndTime()
GameReturns the time at which the game ended, or -1 if it did not yet end.
getEndTime in interface Gamepublic java.lang.String getName()
GameReturn the name of this game.
getName in interface Gamepublic 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 Gamepublic 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 Gamepublic 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 Gamepublic 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)
GameGet the specified turn for given player.
getPlayerTurn in interface Gamepublic java.util.Vector getPlayerTurnHistory(Player player)
GameReturns 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 Gameprotected void addTurn(Turn t)
Add a turn to the game.
public Turn getTurn(int index)
GameGet specified turn of the game.
getTurn in interface Gamepublic java.util.Vector getTurnHistory()
GameReturns 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 Gamepublic void addGameEventListener(GameEventListener gel)
GameAdd given game event listener to the list of listeners that will be notified when a game event occurs.
addGameEventListener in interface Gamepublic void removeGameEventListener(GameEventListener gel)
GameRemove given game event listener from the list of listeners maintained by this object.
removeGameEventListener in interface Gamepublic java.util.Vector getGameEventListeners()
GameGet the collection of game event listeners maintained by this object. The returned collection contains GameEventListener objectgs.
getGameEventListeners in interface Gamepublic void accept(GameVisitor visitor)
GameHave given visitor process the data in this game.
accept in interface Gamepublic 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 | |||||||||