diff options
-rw-r--r-- | src/jrummikub/control/RoundControl.java | 11 | ||||
-rw-r--r-- | test/jrummikub/control/RoundControlTest.java | 3 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java index 4949e2b..231b860 100644 --- a/src/jrummikub/control/RoundControl.java +++ b/src/jrummikub/control/RoundControl.java @@ -81,7 +81,12 @@ public class RoundControl { if (clonedTable.isValid()) { gameState.setTable(clonedTable); - // TODO Win check + System.err.println(gameState.getActivePlayer().getName()); + System.err.println(gameState.getActivePlayer().getHand().getSize()); + if (gameState.getActivePlayer().getHand().getSize() == 0) { + win(); + return; + } } else { gameState.getGameHeap().putBack(tableDiff); dealPenalty(tableDiff.size()); @@ -127,4 +132,8 @@ public class RoundControl { for (int i = 0; i < count + 3; ++i) dealStone(); } + + private void win() { + view.enableWinPanel(true); + } } diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java index 116786e..159df9d 100644 --- a/test/jrummikub/control/RoundControlTest.java +++ b/test/jrummikub/control/RoundControlTest.java @@ -61,6 +61,7 @@ public class RoundControlTest { assertNotNull(view.getTablePanel().rightPlayerName); assertTrue(view.displayStartTurnPanel); assertFalse(view.startTurnEvent.listeners.isEmpty()); + assertFalse(view.displayWinPanel); checkTableDisplay(); } @@ -194,6 +195,8 @@ public class RoundControlTest { view.startTurnEvent.emit(); assertFalse(view.displayStartTurnPanel); + Stone stone = testGameState.players.get(0).hand.stones.remove(0); + newTable.drop(new StoneSet(stone), new Position(0, 0)); testGameState.players.get(0).hand.stones.clear(); resetTurnStart(); view.getPlayerPanel().endTurnEvent.emit(); |