diff options
Diffstat (limited to 'src/jrummikub/control/RoundControl.java')
-rw-r--r-- | src/jrummikub/control/RoundControl.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java index 072aa7f..2080cf4 100644 --- a/src/jrummikub/control/RoundControl.java +++ b/src/jrummikub/control/RoundControl.java @@ -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; } } |