LAden und Speichern geht jetzt immer sauber
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@388 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
41fe3c93b3
commit
70af06e1bf
5 changed files with 87 additions and 44 deletions
|
@ -16,6 +16,7 @@ import jrummikub.view.IView.BottomPanelType;
|
|||
public class ApplicationControl {
|
||||
private SaveControl saveControl;
|
||||
private IView view;
|
||||
private GameControl gameControl;
|
||||
|
||||
/**
|
||||
* Creates a new application control
|
||||
|
@ -53,8 +54,10 @@ public class ApplicationControl {
|
|||
public void handle(GameSettings settings,
|
||||
GameState gameState, IRoundState roundState) {
|
||||
settingsControl.abort();
|
||||
// TODO alles ordentlich beenden (controls)
|
||||
GameControl gameControl = new GameControl(settings,
|
||||
if (gameControl != null){
|
||||
gameControl.abortGame();
|
||||
}
|
||||
gameControl = new GameControl(settings,
|
||||
saveControl, view);
|
||||
addGameControlListeners(gameControl);
|
||||
gameControl.continueGame(gameState, roundState);
|
||||
|
@ -67,7 +70,7 @@ public class ApplicationControl {
|
|||
public void handle(GameSettings settings) {
|
||||
saveControl.setGameSettings(settings);
|
||||
|
||||
GameControl gameControl = new GameControl(settings,
|
||||
gameControl = new GameControl(settings,
|
||||
saveControl, view);
|
||||
addGameControlListeners(gameControl);
|
||||
|
||||
|
|
|
@ -83,10 +83,14 @@ public class GameControl {
|
|||
}
|
||||
|
||||
private void endGame() {
|
||||
removeListeners();
|
||||
endOfGameEvent.emit();
|
||||
}
|
||||
|
||||
private void removeListeners() {
|
||||
for (Connection c : connections) {
|
||||
c.remove();
|
||||
}
|
||||
endOfGameEvent.emit();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,6 +110,16 @@ public class GameControl {
|
|||
}
|
||||
}
|
||||
|
||||
public void abortGame() {
|
||||
removeListeners();
|
||||
if (roundControl != null) {
|
||||
roundControl.abortRound();
|
||||
roundControl = null;
|
||||
}
|
||||
|
||||
view.clearView();
|
||||
}
|
||||
|
||||
private void startRound() {
|
||||
if (roundControl != null) {
|
||||
return;
|
||||
|
|
|
@ -84,6 +84,14 @@ public class RoundControl {
|
|||
prepareTurn();
|
||||
}
|
||||
|
||||
public void abortRound() {
|
||||
removeListeners();
|
||||
if (turnControl != null) {
|
||||
turnControl.abortTurn();
|
||||
turnControl = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareTurn() {
|
||||
boolean isHuman = roundState.getActivePlayer().getPlayerSettings()
|
||||
.getTurnControlType() == HUMAN;
|
||||
|
@ -294,14 +302,18 @@ public class RoundControl {
|
|||
}
|
||||
|
||||
void endOfRound() {
|
||||
for (Connection c : connections) {
|
||||
c.remove();
|
||||
}
|
||||
removeListeners();
|
||||
Score roundScore = score();
|
||||
endOfRoundEvent.emit(roundScore);
|
||||
roundFinished = true;
|
||||
}
|
||||
|
||||
private void removeListeners() {
|
||||
for (Connection c : connections) {
|
||||
c.remove();
|
||||
}
|
||||
}
|
||||
|
||||
private Score score() {
|
||||
List<Boolean> winners = new ArrayList<Boolean>();
|
||||
List<Integer> points = new ArrayList<Integer>();
|
||||
|
|
Reference in a new issue