summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/RoundControl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control/RoundControl.java')
-rw-r--r--src/jrummikub/control/RoundControl.java22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index e9e9453..8aed1ce 100644
--- a/src/jrummikub/control/RoundControl.java
+++ b/src/jrummikub/control/RoundControl.java
@@ -27,7 +27,7 @@ import jrummikub.view.IView;
* Controller that manages a single round of rummikub
*/
public class RoundControl {
- private IRoundState roundState;
+ IRoundState roundState;
private IView view;
private ITable clonedTable;
private Event restartRoundEvent = new Event();
@@ -70,12 +70,7 @@ public class RoundControl {
}
}));
- connections.add(view.getPlayerPanel().getRedealEvent().add(new IListener() {
- @Override
- public void handle() {
- redeal();
- }
- }));
+
prepareTurn();
}
@@ -91,13 +86,20 @@ public class RoundControl {
private void startTurn() {
TurnControl turnControl = new TurnControl(roundState.getActivePlayer()
.getHand(), clonedTable, view, roundState.getTurnNumber() < 1);
- connections.add(turnControl.getEndOfTurnEvent().add(new IListener() {
+ turnControl.getEndOfTurnEvent().add(new IListener() {
@Override
public void handle() {
endOfTurn();
}
- }));
+ });
+
+ turnControl.getRedealEvent().add(new IListener() {
+ @Override
+ public void handle() {
+ redeal();
+ }
+ });
turnControl.startTurn();
}
@@ -322,7 +324,7 @@ public class RoundControl {
}
private void redeal() {
- for (Connection c : connections) {
+ for (Connection c : new ArrayList<Connection>(connections)) {
c.remove();
}
restartRoundEvent.emit();