diff options
author | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-05-10 03:13:11 +0200 |
---|---|---|
committer | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-05-10 03:13:11 +0200 |
commit | a64492dc4b7a08f0d976da10e2da455c20767fd5 (patch) | |
tree | 351699cf01d288d66a0e537bc111fcc37505aa1b /src/jrummikub/control/GameControl.java | |
parent | b14a707d4fca0560437189fecce93cf21c38cbf6 (diff) | |
download | JRummikub-a64492dc4b7a08f0d976da10e2da455c20767fd5.tar JRummikub-a64492dc4b7a08f0d976da10e2da455c20767fd5.zip |
WinPanel funktioniert und ist getestet und überhaupt ist alles ganz toll
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@211 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/GameControl.java')
-rw-r--r-- | src/jrummikub/control/GameControl.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/jrummikub/control/GameControl.java b/src/jrummikub/control/GameControl.java new file mode 100644 index 0000000..ee87bd5 --- /dev/null +++ b/src/jrummikub/control/GameControl.java @@ -0,0 +1,59 @@ +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); + } + +} |