diff options
-rw-r--r-- | mock/jrummikub/view/MockPlayerPanel.java | 9 | ||||
-rw-r--r-- | src/jrummikub/view/IPlayerPanel.java | 11 | ||||
-rw-r--r-- | src/jrummikub/view/impl/PlayerPanel.java | 1 | ||||
-rw-r--r-- | test/jrummikub/control/RoundControlTest.java | 38 |
4 files changed, 59 insertions, 0 deletions
diff --git a/mock/jrummikub/view/MockPlayerPanel.java b/mock/jrummikub/view/MockPlayerPanel.java index d01c027..1a393e8 100644 --- a/mock/jrummikub/view/MockPlayerPanel.java +++ b/mock/jrummikub/view/MockPlayerPanel.java @@ -15,6 +15,10 @@ public class MockPlayerPanel implements IPlayerPanel { public MockEvent sortByGroupsEvent = new MockEvent(); /** */ public MockEvent sortByRunsEvent = new MockEvent(); + /** */ + public boolean inspectOnly; + /** */ + public boolean mayRedeal; @Override public void setTimeLeft(int time) { @@ -42,4 +46,9 @@ public class MockPlayerPanel implements IPlayerPanel { return redealEvent; } + public void setEndTurnMode(boolean inspectOnly, boolean mayRedeal) { + this.inspectOnly = inspectOnly; + this.mayRedeal = mayRedeal; + } + } diff --git a/src/jrummikub/view/IPlayerPanel.java b/src/jrummikub/view/IPlayerPanel.java index 03f04cd..0181a9e 100644 --- a/src/jrummikub/view/IPlayerPanel.java +++ b/src/jrummikub/view/IPlayerPanel.java @@ -43,4 +43,15 @@ public interface IPlayerPanel { * @return the event */ public IEvent getRedealEvent(); + + /** + * Sets the buttons available to end the turn + * + * @param inspectOnly + * true for each player's first turn + * @param mayRedeal + * true if the player is allowed to trigger a redealing of all + * stones + */ + public abstract void setEndTurnMode(boolean inspectOnly, boolean mayRedeal); } diff --git a/src/jrummikub/view/impl/PlayerPanel.java b/src/jrummikub/view/impl/PlayerPanel.java index db2721a..4dd38d6 100644 --- a/src/jrummikub/view/impl/PlayerPanel.java +++ b/src/jrummikub/view/impl/PlayerPanel.java @@ -320,6 +320,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel { } } + @Override public void setEndTurnMode(boolean inspectOnly, boolean mayRedeal) { if (!inspectOnly) { endTurnButton.setText("Zug beenden"); diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java index 68ae825..8c8c67d 100644 --- a/test/jrummikub/control/RoundControlTest.java +++ b/test/jrummikub/control/RoundControlTest.java @@ -905,4 +905,42 @@ public class RoundControlTest { view.playerPanel.redealEvent.emit(); assertTrue(roundRestarted); } + + /** */ + @Test + public void testRedealDisallowed() { + testRound.startRound(); + Hand hand = new Hand(gameSettings); + hand.drop(new Stone(1, RED), new Position(0, 0)); + hand.drop(new Stone(1, BLACK), new Position(0, 0)); + hand.drop(new Stone(1, BLUE), new Position(0, 0)); + testRoundState.players.get(0).hand = hand; + view.startTurnEvent.emit(); + assertTrue(view.playerPanel.inspectOnly); + assertFalse(view.playerPanel.mayRedeal); + for (int i = 0; i < 4; i++) { + view.playerPanel.endTurnEvent.emit(); + view.startTurnEvent.emit(); + } + assertFalse(view.playerPanel.inspectOnly); + } + + /** */ + @Test + public void testRedealAllowed() { + testRound.startRound(); + Hand hand = new Hand(gameSettings); + for (int i = 0; i < 6; i++) { + hand.drop(new Stone(i / 2, RED), new Position(0, 0)); + } + testRoundState.players.get(0).hand = hand; + view.startTurnEvent.emit(); + assertTrue(view.playerPanel.inspectOnly); + assertTrue(view.playerPanel.mayRedeal); + for (int i = 0; i < 4; i++) { + view.playerPanel.endTurnEvent.emit(); + view.startTurnEvent.emit(); + } + assertFalse(view.playerPanel.inspectOnly); + } } |