summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/GameControl.java
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-05-29 20:19:17 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-05-29 20:19:17 +0200
commit794777c2fe8808444d2952d8abe287278d81f119 (patch)
tree014c8dce4acda3da13d1c6eb0e6b27a1a480f3fa /src/jrummikub/control/GameControl.java
parenteb7ccb46c5023fb8a3052f1c6d9fa5d2e384d15e (diff)
downloadJRummikub-794777c2fe8808444d2952d8abe287278d81f119.tar
JRummikub-794777c2fe8808444d2952d8abe287278d81f119.zip
Neuer Button im WinPanel mit funktion
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@309 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/GameControl.java')
-rw-r--r--src/jrummikub/control/GameControl.java35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/jrummikub/control/GameControl.java b/src/jrummikub/control/GameControl.java
index 887b80d..9e967c4 100644
--- a/src/jrummikub/control/GameControl.java
+++ b/src/jrummikub/control/GameControl.java
@@ -9,6 +9,8 @@ import jrummikub.model.IRoundState;
import jrummikub.model.RoundState;
import jrummikub.model.Score;
import jrummikub.util.Connection;
+import jrummikub.util.Event;
+import jrummikub.util.IEvent;
import jrummikub.util.IListener;
import jrummikub.util.IListener1;
import jrummikub.view.IView;
@@ -22,14 +24,15 @@ public class GameControl {
RoundControl roundControl;
private GameState gameState;
private List<Connection> connections = new ArrayList<Connection>();
+ private Event endOfGameEvent = new Event();
/**
* Constructor
*
* @param gameSettings
- * the game settings
+ * the game settings
* @param view
- * the view
+ * the view
*/
public GameControl(GameSettings gameSettings, IView view) {
this.gameSettings = gameSettings;
@@ -45,14 +48,33 @@ public class GameControl {
startRound();
}
}));
- connections.add(view.getFinalScoreEvent().add(new IListener() {
+
+ connections.add(view.getNewGameEvent().add(new IListener() {
+ @Override
+ public void handle() {
+ endGame();
+ }
+ }));
+
+ connections.add(view.getEndProgramEvent().add(new IListener() {
@Override
public void handle() {
- finalScore();
+ endProgram();
}
}));
}
+ public IEvent getEndOfGameEvent() {
+ return endOfGameEvent;
+ }
+
+ private void endGame() {
+ for (Connection c : connections) {
+ c.remove();
+ }
+ endOfGameEvent.emit();
+ }
+
/**
* Game gets started by initializing the first Round
*/
@@ -105,12 +127,13 @@ public class GameControl {
view.getScorePanel().setPlayers(gameSettings.getPlayerList());
view.getScorePanel().setScores(gameState.getScores());
- view.getScorePanel().setAccumulatedScore(gameState.getAccumulatedScore());
+ view.getScorePanel().setAccumulatedScore(
+ gameState.getAccumulatedScore());
view.getScorePanel().update();
view.showScorePanel(true);
}
- private void finalScore() {
+ private void endProgram() {
System.exit(0);
}