org.dartra.games.cricket
Class ScramCricketGame

java.lang.Object
  extended byorg.dartra.standard.PersistentObject
      extended byorg.dartra.standard.StandardGame
          extended byorg.dartra.games.cricket.CricketGame
              extended byorg.dartra.games.cricket.ScramCricketGame
All Implemented Interfaces:
Game, Match, Persistent

public class ScramCricketGame
extends CricketGame
implements Match

CricketGame version where one player is the blocker, and the other one is the scorer. A number hit once by the blocker, cannot be hit by the scorer anymore. When the blocker has closed all numbers, the roles are switched. The winner is the player that can score the most points.

Author:
Bieke Meeussen

Nested Class Summary
 class ScramCricketGame.ScramCricketGamePart
          One part of the ScramCricketGame; Player 0 is the blocker and player 1 the scorer
 
Field Summary
protected static java.lang.String[] DEFAULT_SCRAM_GOALS
           
 
Fields inherited from class org.dartra.games.cricket.CricketGame
DEFAULT_GOALS, goalsMap
 
Constructor Summary
ScramCricketGame(StandardBoard board, Player[] players)
           
ScramCricketGame(StandardBoard board, Player[] players, StringProperties props)
           
 
Method Summary
protected  void addGame(Game game)
          Add a game to the match.
protected  void checkScramGameOver()
          Checks if this game has a winner, and sets the winner.
 Game getCurrentGame()
          Get the currently active game of this match.
 Player getCurrentPlayer()
          Returns the current player of the game, the player that is currently on throw.
 Game getGame(int index)
          Return specified game of this match.
 java.util.Vector getGames()
          Return a list of all games played in this match so far.
 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.
 void registerHit(Zone targetZone, Hit hit)
          Register the hit of a dart on the board.
 void start()
          Starts the scram game.
protected  void startNewGame()
          Starts a new game in this match.
 
Methods inherited from class org.dartra.games.cricket.CricketGame
addHitToTracker, addPlayerThrow, addTurnToTracker, calculateWinner, changePlayer, createTracker, emptyTurn, findPlace, gameOver, getGoals, getGoalsMap, getProperties, highestScoreNumber, highestScoreZone, isClosedByOtherPlayer, isClosedByPlayer, isUsePoints, multiplierToClose, score, setGoals, setUsePoints, suggestZone, toString, turnOver, wasClosedByOtherPlayer, wasClosedByPlayer, zoneToCloseHighestOpenForPlayer
 
Methods inherited from class org.dartra.standard.StandardGame
accept, addGameEventListener, addTurn, getBoard, getCurrentTurn, getEndTime, getFirstPlayer, getGameEventListeners, getName, getPlayer, getPlayers, getPlayerTurn, getPlayerTurnHistory, getStartTime, getTurn, getTurnHistory, getWinner, removeGameEventListener, setEndTime, setFirstPlayer, setPlayers, setStartTime, setWinner, 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.Game
accept, addGameEventListener, getBoard, getCurrentTurn, getEndTime, getFirstPlayer, getGameEventListeners, getName, getPlayer, getPlayers, getPlayerTurn, getPlayerTurnHistory, getStartTime, getTurn, getTurnHistory, getWinner, removeGameEventListener, setFirstPlayer, setWinner, undoHit
 
Methods inherited from interface org.dartra.framework.Persistent
getId, setId
 

Field Detail

DEFAULT_SCRAM_GOALS

protected static final java.lang.String[] DEFAULT_SCRAM_GOALS
Constructor Detail

ScramCricketGame

public ScramCricketGame(StandardBoard board,
                        Player[] players)

ScramCricketGame

public ScramCricketGame(StandardBoard board,
                        Player[] players,
                        StringProperties props)
Method Detail

start

public void start()

Starts the scram game. Sets the starting time, and starts the first part.

Specified by:
start in interface Game
Overrides:
start in class StandardGame

startNewGame

protected void startNewGame()

Starts a new game in this match.


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.

Specified by:
getObjective in interface Game
Overrides:
getObjective in class CricketGame
See Also:
Game.getObjective()

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.

Specified by:
registerHit in interface Game
Overrides:
registerHit in class CricketGame
See Also:
Game.registerHit(org.dartra.framework.Zone, org.dartra.framework.Hit)

getPlayerScore

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

Get the current score for given player in this game.

Specified by:
getPlayerScore in interface Game
Overrides:
getPlayerScore in class CricketGame
See Also:
Game.getPlayerScore(org.dartra.framework.Player)

checkScramGameOver

protected void checkScramGameOver()

Checks if this game has a winner, and sets the winner. The winner is the player that scored most as a scorer.


addGame

protected void addGame(Game game)

Add a game to the match.


getCurrentGame

public Game getCurrentGame()

Get the currently active game of this match. For a standard match, this is the last game of the match, or null if the match does not yet contain any games.

Specified by:
getCurrentGame in interface Match

getGame

public Game getGame(int index)
Description copied from interface: Match

Return specified game of this match.

Specified by:
getGame in interface Match

getCurrentPlayer

public Player getCurrentPlayer()
Description copied from interface: Game

Returns the current player of the game, the player that is currently on throw.

Specified by:
getCurrentPlayer in interface Game
Overrides:
getCurrentPlayer in class StandardGame

getGames

public java.util.Vector getGames()
Description copied from interface: Match

Return a list of all games played in this match so far. The returned list contains Game objects.

Specified by:
getGames in interface Match