diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jrummikub/control/TurnControl.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/jrummikub/control/TurnControl.java b/src/jrummikub/control/TurnControl.java index 417c7b4..840b0e9 100644 --- a/src/jrummikub/control/TurnControl.java +++ b/src/jrummikub/control/TurnControl.java @@ -1,7 +1,11 @@ package jrummikub.control; +import java.util.ArrayList; +import java.util.List; + import jrummikub.model.IHand; import jrummikub.model.ITable; +import jrummikub.util.Connection; import jrummikub.util.Event; import jrummikub.util.IEvent; import jrummikub.util.IListener; @@ -13,7 +17,7 @@ public class TurnControl { private ITurnTimer timer; private IView view; private Event endOfTurnEvent = new Event(); - IListener endOfTurnListener; + List<Connection> connections = new ArrayList<Connection>(); public TurnControl(IHand hand, ITable table, IView view) { this.hand = hand; @@ -32,15 +36,15 @@ public class TurnControl { public void startTurn() { - endOfTurnListener = new IListener() { + IListener endOfTurnListener = new IListener() { @Override public void handle() { endOfTurn(); } }; - timer.getTimeRunOutEvent().add(endOfTurnListener); - view.getPlayerPanel().getEndTurnEvent().add(endOfTurnListener); + connections.add(timer.getTimeRunOutEvent().add(endOfTurnListener)); + connections.add(view.getPlayerPanel().getEndTurnEvent().add(endOfTurnListener)); view.getPlayerPanel().getHandPanel().setStones(hand.clone()); view.enableStartTurnPanel(false); @@ -59,7 +63,9 @@ public class TurnControl { private void endOfTurn() { timer.stopTimer(); endOfTurnEvent.emit(); - view.getPlayerPanel().getEndTurnEvent().remove(endOfTurnListener); + for (Connection c : connections) { + c.remove(); + } } public IEvent getEndOfTurnEvent() { |