Implement score panel
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@298 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
eea456991c
commit
9cf3dc09ae
8 changed files with 270 additions and 14 deletions
|
@ -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() {
|
||||
|
|
Reference in a new issue