diff options
author | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-04 18:47:12 +0200 |
---|---|---|
committer | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-04 18:47:12 +0200 |
commit | ac08bc112f161e26f9dfc7a8f6f6c632597e36f0 (patch) | |
tree | 1d47dc3acb01db943010a22d66719af3baa16b0d | |
parent | 3cd6dee363700133ec827ea9fdb40ae302b35459 (diff) | |
download | JRummikub-ac08bc112f161e26f9dfc7a8f6f6c632597e36f0.tar JRummikub-ac08bc112f161e26f9dfc7a8f6f6c632597e36f0.zip |
Implemented end of turn event handling, tested
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@112 72836036-5685-4462-b002-a69064685172
-rw-r--r-- | src/jrummikub/control/TurnControl.java | 21 | ||||
-rw-r--r-- | test/jrummikub/control/TurnControlTest.java | 7 |
2 files changed, 25 insertions, 3 deletions
diff --git a/src/jrummikub/control/TurnControl.java b/src/jrummikub/control/TurnControl.java index 612597a..40782de 100644 --- a/src/jrummikub/control/TurnControl.java +++ b/src/jrummikub/control/TurnControl.java @@ -5,6 +5,7 @@ import jrummikub.model.IHand; import jrummikub.model.ITable; import jrummikub.util.Event; import jrummikub.util.IEvent; +import jrummikub.util.IListener; import jrummikub.view.IView; public class TurnControl { @@ -19,6 +20,7 @@ public class TurnControl { this.hand = hand; this.table = table; this.view = view; + setup(); } /** Test only constructor **/ @@ -28,6 +30,20 @@ public class TurnControl { this.table = table; this.view = view; this.timer = testTimer; + setup(); + } + + private void setup() { + + IListener endOfTurnListener = new IListener() { + + @Override + public void handle() { + endOfTurn(); + } + }; + timer.getTimeRunOutEvent().add(endOfTurnListener); + view.getPlayerPanel().getEndTurnEvent().add(endOfTurnListener); } private void sortByValue() { @@ -38,6 +54,11 @@ public class TurnControl { } + private void endOfTurn() { + timer.stopTimer(); + endOfTurnEvent.emit(); + } + public IEvent getEndOfTurnEvent() { return endOfTurnEvent; } diff --git a/test/jrummikub/control/TurnControlTest.java b/test/jrummikub/control/TurnControlTest.java index 8ba7bc4..288214e 100644 --- a/test/jrummikub/control/TurnControlTest.java +++ b/test/jrummikub/control/TurnControlTest.java @@ -19,7 +19,8 @@ import static org.junit.Assert.*; public class TurnControlTest { class MockTimer implements ITurnTimer { - boolean timerRunning; + public boolean timerRunning; + public Event timeRunOutEvent = new Event(); @Override public void startTimer() { @@ -33,7 +34,7 @@ public class TurnControlTest { @Override public IEvent getTimeRunOutEvent() { - return null; + return timeRunOutEvent; } } @@ -82,7 +83,7 @@ public class TurnControlTest { } }); - mockView.playerPanel.endTurnEvent.emit(); + mockTimer.timeRunOutEvent.emit(); assertTrue(eventFired); assertFalse(mockTimer.timerRunning); |