From 9cf3dc09ae319b6e627a4c52923bbc325137ef34 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 29 May 2011 15:50:30 +0200 Subject: Implement score panel git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@298 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/GameControl.java | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/jrummikub/control') 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() { @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() { -- cgit v1.2.3