summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-05-05 19:49:57 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-05-05 19:49:57 +0200
commit8ad8432d857fb347ea22cd87797305b896c24e55 (patch)
tree5679db8b23ae264a5b0a92ce394e2ccc35dcf0c8
parentcce3c6bc6e7f7473a2c5fc9462fac864fd075714 (diff)
downloadJRummikub-8ad8432d857fb347ea22cd87797305b896c24e55.tar
JRummikub-8ad8432d857fb347ea22cd87797305b896c24e55.zip
Remove listener in turn control and have explicit turn start method
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@148 72836036-5685-4462-b002-a69064685172
-rw-r--r--src/jrummikub/control/TurnControl.java8
-rw-r--r--test/jrummikub/control/TurnControlTest.java1
2 files changed, 5 insertions, 4 deletions
diff --git a/src/jrummikub/control/TurnControl.java b/src/jrummikub/control/TurnControl.java
index f73a6a4..417c7b4 100644
--- a/src/jrummikub/control/TurnControl.java
+++ b/src/jrummikub/control/TurnControl.java
@@ -13,13 +13,13 @@ public class TurnControl {
private ITurnTimer timer;
private IView view;
private Event endOfTurnEvent = new Event();
+ IListener endOfTurnListener;
public TurnControl(IHand hand, ITable table, IView view) {
this.hand = hand;
this.table = table;
this.view = view;
this.timer = new TurnTimer(view);
- setup();
}
/** Test only constructor **/
@@ -28,12 +28,11 @@ public class TurnControl {
this.table = table;
this.view = view;
this.timer = testTimer;
- setup();
}
- private void setup() {
+ public void startTurn() {
- IListener endOfTurnListener = new IListener() {
+ endOfTurnListener = new IListener() {
@Override
public void handle() {
@@ -60,6 +59,7 @@ public class TurnControl {
private void endOfTurn() {
timer.stopTimer();
endOfTurnEvent.emit();
+ view.getPlayerPanel().getEndTurnEvent().remove(endOfTurnListener);
}
public IEvent getEndOfTurnEvent() {
diff --git a/test/jrummikub/control/TurnControlTest.java b/test/jrummikub/control/TurnControlTest.java
index 685a745..bdec8b8 100644
--- a/test/jrummikub/control/TurnControlTest.java
+++ b/test/jrummikub/control/TurnControlTest.java
@@ -60,6 +60,7 @@ public class TurnControlTest {
mockTable = new MockTable();
mockHand = new MockHand();
testControl = new TurnControl(mockHand, mockTable, mockView, mockTimer);
+ testControl.startTurn();
}
@Test