summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control
diff options
context:
space:
mode:
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() {