summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control/network')
-rw-r--r--src/jrummikub/control/network/NetworkRoundControl.java65
1 files changed, 37 insertions, 28 deletions
diff --git a/src/jrummikub/control/network/NetworkRoundControl.java b/src/jrummikub/control/network/NetworkRoundControl.java
index af7f675..05a3424 100644
--- a/src/jrummikub/control/network/NetworkRoundControl.java
+++ b/src/jrummikub/control/network/NetworkRoundControl.java
@@ -4,7 +4,6 @@ import jrummikub.control.RoundControl;
import jrummikub.control.turn.ITurnControl;
import jrummikub.model.IRoundState;
import jrummikub.model.ITable;
-import jrummikub.model.PlayerSettings.Type;
import jrummikub.util.IListener;
import jrummikub.util.IListener1;
import jrummikub.view.IView;
@@ -14,6 +13,7 @@ import jrummikub.view.IView;
*/
public class NetworkRoundControl extends RoundControl {
private IConnectionControl connectionControl;
+ private boolean wasActive;
private boolean currentlyActive;
/**
@@ -33,6 +33,7 @@ public class NetworkRoundControl extends RoundControl {
super(roundState, view, false);
this.connectionControl = connectionControl;
+ wasActive = startActive;
currentlyActive = startActive;
connections.add(connectionControl.getRoundStateUpdateEvent().add(
@@ -40,22 +41,21 @@ public class NetworkRoundControl extends RoundControl {
@Override
public void handle(IRoundState state) {
setRoundState(state);
+ prepareTurn();
}
}));
- connections.add(connectionControl.getTurnStartEvent().add(
- new IListener() {
- @Override
- public void handle() {
- startTurn();
- }
- }));
- connections.add(connectionControl.getNextPlayerEvent().add(
- new IListener() {
- @Override
- public void handle() {
- NetworkRoundControl.super.nextPlayer();
- }
- }));
+ connections.add(connectionControl.getTurnStartEvent().add(new IListener() {
+ @Override
+ public void handle() {
+ NetworkRoundControl.super.startTurn();
+ }
+ }));
+ connections.add(connectionControl.getNextPlayerEvent().add(new IListener() {
+ @Override
+ public void handle() {
+ NetworkRoundControl.super.nextPlayer();
+ }
+ }));
}
@Override
@@ -69,30 +69,39 @@ public class NetworkRoundControl extends RoundControl {
}
@Override
- protected ITurnControl createTurnControl(Type type) {
- switch (type) {
- case HUMAN:
- currentlyActive = true;
- break;
- case NETWORK:
- currentlyActive = false;
- break;
- }
-
+ protected ITurnControl createTurnControl() {
if (!currentlyActive) {
return new NetworkTurnControl(connectionControl);
}
- return super.createTurnControl(type);
+ return super.createTurnControl();
}
@Override
protected void prepareTurn() {
- if (currentlyActive) {
- connectionControl.startTurn();
+ switch (roundState.getActivePlayer().getPlayerSettings().getType()) {
+ case HUMAN:
+ currentlyActive = true;
+ break;
+ case NETWORK:
+ currentlyActive = false;
+ break;
}
doPrepareTurn();
+
+ if (showStartTurnPanel() == null) {
+ if (currentlyActive) {
+ connectionControl.startTurn();
+ }
+ }
+ }
+
+ @Override
+ protected void startTurn() {
+ if (currentlyActive) {
+ connectionControl.startTurn();
+ }
}
@Override