|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A game of darts. A number of players play a game of darts on a particular board. Those players will have their game property set appropriately.
Game objects create the internal game related objects used to manage their state. As such, a Game object is a factory for GameEvent, Objective, Score, Turn and Throw objects.
A game object exposes the following protocol:
Game game=new SomeGame(...); game.start(); while (game.getWinner()==null) { Objective o=game.getObjective(); //do whatever is needed to get the user to obtain the objective Zone targetZone=...; Hit hit=...; game.registerHit(targetZone, hit); }
Game objects have reference semantics. Each Game object represents a unique darts game.
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. |
Board |
getBoard()
Returns the board the game is played on. |
Player |
getCurrentPlayer()
Returns the current player of the game, the player that is currently on throw. |
Turn |
getCurrentTurn()
Return 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. |
Objective |
getObjective()
Get the current objective of the game: the current player should try to hit a zone of the board, or should end this turn. |
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. |
Score |
getPlayerScore(Player player)
Get the current score for given player in this 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. |
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 |
registerHit(Zone targetZone,
Hit hit)
Register the hit of a dart on the board. |
void |
removeGameEventListener(GameEventListener gel)
Remove given game event listener from the list of listeners maintained by this object. |
void |
setFirstPlayer(Player player)
Set the player that will be the first to throw. |
void |
setWinner(Player winner)
Set the player that won the game. |
void |
start()
Start the game. |
boolean |
undoHit()
Undo the effect of the last hit that was registered via registerHit() method. |
Methods inherited from interface org.dartra.framework.Persistent |
getId, setId |
Method Detail |
public java.lang.String getName()
Return the name of this game.
public Board getBoard()
Returns the board the game is played on.
public java.util.Vector getPlayers()
Returns the list of players participating in the game. The returned list contains Player objects.
public Player getPlayer(int index)
Get a particular player participating in the game.
public void setFirstPlayer(Player player)
Set the player that will be the first to throw.
public Player getFirstPlayer()
Returns the player that will be the first to throw.
public void setWinner(Player winner)
Set the player that won the game.
public Player getWinner()
Returns the player that won the game, or null if no winner has been established yet.
public long getStartTime()
Returns the time at which the game started, or -1 if it did not yet start.
public long getEndTime()
Returns the time at which the game ended, or -1 if it did not yet end.
public void start()
Start the game.
public Objective getObjective()
Get the current objective of the game: the current player should try to hit a zone of the board, or should end this turn.
public void registerHit(Zone targetZone, Hit hit)
Register the hit of a dart on the board. A particular zone of the board was targetted.
public boolean undoHit()
Undo the effect of the last hit that was registered via registerHit() method. Returns whether or not the undo was successfull.
public Score getPlayerScore(Player player)
Get the current score for given player in this game.
public Player getCurrentPlayer()
Returns the current player of the game, the player that is currently on throw.
public Turn getCurrentTurn()
Return the currently active turn of the game.
public Turn getPlayerTurn(Player player, int index)
Get the specified turn for given player.
public java.util.Vector getPlayerTurnHistory(Player player)
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.
public Turn getTurn(int index)
Get specified turn of the game.
public java.util.Vector getTurnHistory()
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.
public void addGameEventListener(GameEventListener gel)
Add given game event listener to the list of listeners that will be notified when a game event occurs.
public void removeGameEventListener(GameEventListener gel)
Remove given game event listener from the list of listeners maintained by this object.
public java.util.Vector getGameEventListeners()
Get the collection of game event listeners maintained by this object. The returned collection contains GameEventListener objectgs.
public void accept(GameVisitor visitor)
Have given visitor process the data in this game.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |