summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/network
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-22 03:08:37 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-22 03:08:37 +0200
commitd6c4da62243310b85a82e73e55249de9af7fdb11 (patch)
treeecdb215533c41a9d6f02c0770ea76a38f8b4867b /src/jrummikub/control/network
parent62a55c0a918b1d91338a68ee89211006e11785bf (diff)
downloadJRummikub-d6c4da62243310b85a82e73e55249de9af7fdb11.tar
JRummikub-d6c4da62243310b85a82e73e55249de9af7fdb11.zip
Show in start turn panel if a player has redealed or drawn the last stone
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@570 72836036-5685-4462-b002-a69064685172
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