Implemented special case round end (heap empty)
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@262 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
b20961b89d
commit
d9a0b0e37d
7 changed files with 82 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
|||
package jrummikub.control;
|
||||
|
||||
import jrummikub.model.GameSettings;
|
||||
import jrummikub.model.IRoundState;
|
||||
import jrummikub.model.RoundState;
|
||||
import jrummikub.util.IListener;
|
||||
import jrummikub.view.IView;
|
||||
|
@ -51,7 +52,7 @@ public class GameControl {
|
|||
return;
|
||||
}
|
||||
|
||||
RoundState roundState = new RoundState(gameSettings);
|
||||
IRoundState roundState = new RoundState(gameSettings);
|
||||
|
||||
roundControl = new RoundControl(roundState, view);
|
||||
roundControl.getEndRoundEvent().add(new IListener() {
|
||||
|
|
|
@ -28,6 +28,7 @@ public class RoundControl {
|
|||
private ITable clonedTable;
|
||||
private Event endRoundEvent = new Event();
|
||||
private List<Connection> connections = new ArrayList<Connection>();
|
||||
private boolean roundFinished;
|
||||
|
||||
/**
|
||||
* Create a new RoundControl using the given gameState and view
|
||||
|
@ -123,8 +124,24 @@ public class RoundControl {
|
|||
|
||||
private void endOfTurn() {
|
||||
checkTurn();
|
||||
roundState.nextPlayer();
|
||||
prepareTurn();
|
||||
|
||||
if (roundState.getLastPlayer() == null) {
|
||||
if (roundState.getGameHeap().getSize() == 0) {
|
||||
roundState.setLastPlayer(roundState.getNthNextPlayer(-1));
|
||||
} else {
|
||||
roundState.nextPlayer();
|
||||
}
|
||||
} else {
|
||||
if (roundState.getActivePlayer() == roundState.getLastPlayer()) {
|
||||
// TODO check who has won
|
||||
win();
|
||||
} else {
|
||||
roundState.nextPlayer();
|
||||
}
|
||||
}
|
||||
if (!roundFinished) {
|
||||
prepareTurn();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkTurn() {
|
||||
|
@ -224,5 +241,6 @@ public class RoundControl {
|
|||
}
|
||||
endRoundEvent.emit();
|
||||
view.enableWinPanel(true);
|
||||
roundFinished = true;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue