jrummikub.control
Class GameControl

java.lang.Object
  extended by jrummikub.control.GameControl
Direct Known Subclasses:
NetworkGameControl

public class GameControl
extends java.lang.Object

Controls a Game, at some point including all Rounds, starts new Rounds


Field Summary
protected  java.util.List<Connection> connections
           
protected  Event endOfGameEvent
           
protected  GameSettings gameSettings
           
protected  GameState gameState
           
protected  RoundControl roundControl
           
protected  SaveControl saveControl
           
protected  IView view
           
 
Constructor Summary
GameControl(GameSettings gameSettings, SaveControl saveControl, IView view)
          Constructor
 
Method Summary
 void abortGame()
          Clean abortion of a running game when another one is loaded or when a new one is started
 void continueGame(GameState gameState, IRoundState roundState)
          Continues game after loading
protected  RoundControl createRoundControl(IRoundState roundState)
          Creates a new round control with the specified round state
protected  IRoundState createRoundState()
          Creates a new round State
private  void endGame()
          Ends the running game
private  void endOfRound(Score roundScore)
          Sets the score and default values for saving when round ends
private  void endProgram()
          Exits System without warnings if no game control is active
 IEvent getEndOfGameEvent()
          Is emitted when the user ends the game and start a new one
private  void prepareRound(IRoundState roundState)
          Prepare a new round by setting start player, adding listeners
private  void removeListeners()
          Removes all listeners from the connection
private  void restartRound()
          Restarts round after redealing
private  void showScorePanel()
          Sets score panel visible
protected  void showWinPanel()
           
 void startGame()
          Game gets started by initializing the first Round
protected  void startRound()
          Start a new round within the existing game
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

saveControl

protected SaveControl saveControl

gameSettings

protected GameSettings gameSettings

view

protected IView view

roundControl

protected RoundControl roundControl

gameState

protected GameState gameState

connections

protected java.util.List<Connection> connections

endOfGameEvent

protected Event endOfGameEvent
Constructor Detail

GameControl

public GameControl(GameSettings gameSettings,
                   SaveControl saveControl,
                   IView view)
Constructor

Parameters:
gameSettings - the game settings
saveControl - the save control
view - the view
Method Detail

getEndOfGameEvent

public IEvent getEndOfGameEvent()
Is emitted when the user ends the game and start a new one

Returns:
the endOfGameEvent

endGame

private void endGame()
Ends the running game


removeListeners

private void removeListeners()
Removes all listeners from the connection


startGame

public void startGame()
Game gets started by initializing the first Round


continueGame

public void continueGame(GameState gameState,
                         IRoundState roundState)
Continues game after loading

Parameters:
gameState - the saved GameState (Players, startplayer, points)
roundState - the saved RoundState (activePlayer, Table, heap etc)

abortGame

public void abortGame()
Clean abortion of a running game when another one is loaded or when a new one is started


startRound

protected void startRound()
Start a new round within the existing game


prepareRound

private void prepareRound(IRoundState roundState)
Prepare a new round by setting start player, adding listeners

Parameters:
roundState - of current round

createRoundState

protected IRoundState createRoundState()
Creates a new round State

Returns:
the round state

createRoundControl

protected RoundControl createRoundControl(IRoundState roundState)
Creates a new round control with the specified round state

Parameters:
roundState - for new round control
Returns:
the round control

restartRound

private void restartRound()
Restarts round after redealing


endOfRound

private void endOfRound(Score roundScore)
Sets the score and default values for saving when round ends

Parameters:
roundScore - score for ended round

showScorePanel

private void showScorePanel()
Sets score panel visible


showWinPanel

protected void showWinPanel()

endProgram

private void endProgram()
Exits System without warnings if no game control is active