summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/GameControl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control/GameControl.java')
-rw-r--r--src/jrummikub/control/GameControl.java31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/jrummikub/control/GameControl.java b/src/jrummikub/control/GameControl.java
index fb3fcf8..985781a 100644
--- a/src/jrummikub/control/GameControl.java
+++ b/src/jrummikub/control/GameControl.java
@@ -33,11 +33,11 @@ public class GameControl {
* Constructor
*
* @param gameSettings
- * the game settings
+ * the game settings
* @param saveControl
- * the save control
+ * the save control
* @param view
- * the view
+ * the view
*/
public GameControl(GameSettings gameSettings, SaveControl saveControl,
IView view) {
@@ -96,6 +96,16 @@ public class GameControl {
startRound();
}
+ public void continueGame(GameState gameState, IRoundState roundState) {
+ this.gameState = gameState;
+ if (roundState == null) {
+ showScorePanel();
+ } else {
+ prepareRound(roundState);
+ roundControl.continueRound();
+ }
+ }
+
private void startRound() {
if (roundControl != null) {
return;
@@ -104,6 +114,11 @@ public class GameControl {
view.showScorePanel(false);
IRoundState roundState = new RoundState(gameSettings);
+ prepareRound(roundState);
+ roundControl.startRound();
+ }
+
+ private void prepareRound(IRoundState roundState) {
saveControl.setRoundState(roundState);
roundState.setActivePlayerNumber(gameState.getFirstRoundFirstPlayer()
@@ -125,8 +140,6 @@ public class GameControl {
restartRound();
}
});
-
- roundControl.startRound();
}
private void restartRound() {
@@ -136,13 +149,19 @@ public class GameControl {
private void endOfRound(Score roundScore) {
gameState.getScores().add(roundScore);
+ saveControl.setRoundState(null);
roundControl = null;
+ showScorePanel();
+ }
+
+ private void showScorePanel() {
view.setBottomPanel(BottomPanelType.WIN_PANEL);
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);
}