From d6c4da62243310b85a82e73e55249de9af7fdb11 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 22 Jun 2011 03:08:37 +0200 Subject: 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 --- .../control/network/NetworkRoundControl.java | 65 ++++++++++++---------- 1 file changed, 37 insertions(+), 28 deletions(-) (limited to 'src/jrummikub/control/network') 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 -- cgit v1.2.3