org.dartra.games.golf
Class GolfGame

java.lang.Object
  extended byorg.dartra.standard.PersistentObject
      extended byorg.dartra.standard.StandardGame
          extended byorg.dartra.games.golf.GolfGame
All Implemented Interfaces:
Game, Persistent

public class GolfGame
extends StandardGame

Classic darts golf game.

Author:
Bieke Meeussen

Field Summary
static int EIGHTEEN_HOLES
           
static int NINE_HOLES
           
 
Constructor Summary
GolfGame(StandardBoard board, Player[] players, int nrHoles)
          Constructor taking the number of holes and an array of players as arguments.
GolfGame(StandardBoard board, Player[] players, StringProperties props)
           
 
Method Summary
 int getNrHoles()
           
 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.
 Score getPlayerScore(Player player)
          Get the current score for given player in this game.
 StringProperties getProperties()
          Subclasses should implement this to properly return their game specific properties (for instance the "start score" for an x01 game).
 void registerHit(Zone targetZone, Hit hit)
          Register the hit of a dart on the board.
 java.lang.String toString()
           
 
Methods inherited from class org.dartra.standard.StandardGame
accept, addGameEventListener, addTurn, getBoard, getCurrentPlayer, getCurrentTurn, getEndTime, getFirstPlayer, getGameEventListeners, getName, getPlayer, getPlayers, getPlayerTurn, getPlayerTurnHistory, getStartTime, getTurn, getTurnHistory, getWinner, removeGameEventListener, setEndTime, setFirstPlayer, setPlayers, setStartTime, setWinner, start, undoHit
 
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.Persistent
getId, setId
 

Field Detail

EIGHTEEN_HOLES

public static final int EIGHTEEN_HOLES
See Also:
Constant Field Values

NINE_HOLES

public static final int NINE_HOLES
See Also:
Constant Field Values
Constructor Detail

GolfGame

public GolfGame(StandardBoard board,
                Player[] players,
                StringProperties props)

GolfGame

public GolfGame(StandardBoard board,
                Player[] players,
                int nrHoles)

Constructor taking the number of holes and an array of players as arguments.

Parameters:
board -
players - Array of players who will be playing this game. A minimum of two players is required.
nrHoles - Number of holes for this Golf game. Should be GolfGame.EIGHTEEN_HOLES or GolfGame.NINE_HOLES.
Method Detail

getObjective

public Objective getObjective()
Description copied from interface: Game

Get the current objective of the game: the current player should try to hit a zone of the board, or should end this turn.


registerHit

public void registerHit(Zone targetZone,
                        Hit hit)
Description copied from interface: Game

Register the hit of a dart on the board. A particular zone of the board was targetted.


getPlayerScore

public Score getPlayerScore(Player player)
Description copied from interface: Game

Get the current score for given player in this game.


toString

public java.lang.String toString()
Overrides:
toString in class StandardGame

getNrHoles

public int getNrHoles()

getProperties

public StringProperties getProperties()
Description copied from class: 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.

Specified by:
getProperties in class StandardGame