package jrummikub.control;
import jrummikub.model.GameState;
import jrummikub.util.IListener;
import jrummikub.view.IView;
/**
* Controls a Game, at some point including all Rounds, starts new Rounds
*/
public class GameControl {
private IView view;
private RoundControl roundControl;
* Constructor
*
* @param view
* the view
public GameControl(IView view) {
this.view = view;
view.getNewGameEvent().add(new IListener() {
@Override
public void handle() {
startRound();
}
});
view.getQuitEvent().add(new IListener() {
quitProgram();
* Game gets started by initializing the first Round
public void startGame() {
private void startRound() {
if (roundControl != null) {
return;
GameState gameState = new GameState();
roundControl = new RoundControl(gameState, view);
roundControl.getEndRoundEvent().add(new IListener() {
roundControl = null;
roundControl.startRound();
private void quitProgram() {
System.exit(0);