package jrummikub.control; import jrummikub.model.GameState; import jrummikub.util.IListener; import jrummikub.view.IView; public class GameControl { final static int HAND_HEIGHT = 2; final static int HAND_WIDTH = 14; private IView view; private RoundControl roundControl; public GameControl(IView view) { this.view = view; view.getPlayerPanel().getHandPanel().setHandHeight(HAND_HEIGHT); view.getPlayerPanel().getHandPanel().setHandWidth(HAND_WIDTH); view.getNewGameEvent().add(new IListener() { @Override public void handle() { startRound(); } }); view.getQuitEvent().add(new IListener() { @Override public void handle() { quitProgram(); } }); } public void startGame() { startRound(); } private void startRound() { if (roundControl != null) { return; } GameState gameState = new GameState(); roundControl = new RoundControl(gameState, view); roundControl.getEndRoundEvent().add(new IListener() { @Override public void handle() { roundControl = null; } }); roundControl.startRound(); } private void quitProgram() { System.exit(0); } }