summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-29 15:50:30 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-29 15:50:30 +0200
commit9cf3dc09ae319b6e627a4c52923bbc325137ef34 (patch)
tree73d6391aa1fb286770e0cdec1c502fc63ad61ae2 /src/jrummikub/control
parenteea456991cc9e3d29ab51e8907b0374a61c77a96 (diff)
downloadJRummikub-9cf3dc09ae319b6e627a4c52923bbc325137ef34.tar
JRummikub-9cf3dc09ae319b6e627a4c52923bbc325137ef34.zip
Implement score panel
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@298 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r--src/jrummikub/control/GameControl.java29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/jrummikub/control/GameControl.java b/src/jrummikub/control/GameControl.java
index 0ae05a6..887b80d 100644
--- a/src/jrummikub/control/GameControl.java
+++ b/src/jrummikub/control/GameControl.java
@@ -34,9 +34,10 @@ public class GameControl {
public GameControl(GameSettings gameSettings, IView view) {
this.gameSettings = gameSettings;
this.view = view;
-
+
gameState = new GameState();
- gameState.setFirstRoundFirstPlayer((int)(Math.random() * gameSettings.getPlayerList().size()));
+ gameState.setFirstRoundFirstPlayer((int) (Math.random() * gameSettings
+ .getPlayerList().size()));
connections.add(view.getNewRoundEvent().add(new IListener() {
@Override
@@ -64,20 +65,22 @@ public class GameControl {
return;
}
+ view.showScorePanel(false);
+
IRoundState roundState = new RoundState(gameSettings);
- // TODO: add number of already played rounds
- roundState.setActivePlayerNumber(gameState.getFirstRoundFirstPlayer());
-
+ roundState.setActivePlayerNumber(gameState.getFirstRoundFirstPlayer()
+ + gameState.getScores().size());
+
roundControl = new RoundControl(roundState, view);
roundControl.getEndOfRoundEvent().add(new IListener1<Score>() {
@Override
public void handle(Score roundScore) {
- endOfRound();
+ endOfRound(roundScore);
}
});
-
+
roundControl.getRestartRoundEvent().add(new IListener() {
@Override
@@ -88,15 +91,23 @@ public class GameControl {
roundControl.startRound();
}
-
+
private void restartRound() {
roundControl = null;
startRound();
}
- private void endOfRound() {
+ private void endOfRound(Score roundScore) {
+ gameState.getScores().add(roundScore);
+
roundControl = null;
view.enableWinPanel(true);
+
+ view.getScorePanel().setPlayers(gameSettings.getPlayerList());
+ view.getScorePanel().setScores(gameState.getScores());
+ view.getScorePanel().setAccumulatedScore(gameState.getAccumulatedScore());
+ view.getScorePanel().update();
+ view.showScorePanel(true);
}
private void finalScore() {