summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/network
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-19 23:19:01 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-19 23:19:01 +0200
commit9df549727672e8df768d46e3ef1fb0c7957f0f89 (patch)
tree3ad4ef018dfb850aee56771c4227d9ce0b32be7e /src/jrummikub/control/network
parent890051a3e93a31d0e1a6bc1a1d1bc14a7205b8b9 (diff)
downloadJRummikub-9df549727672e8df768d46e3ef1fb0c7957f0f89.tar
JRummikub-9df549727672e8df768d46e3ef1fb0c7957f0f89.zip
Make NetworkRoundControl test work
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@496 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/network')
-rw-r--r--src/jrummikub/control/network/NetworkRoundControl.java44
1 files changed, 34 insertions, 10 deletions
diff --git a/src/jrummikub/control/network/NetworkRoundControl.java b/src/jrummikub/control/network/NetworkRoundControl.java
index d7de9ea..a05f8ae 100644
--- a/src/jrummikub/control/network/NetworkRoundControl.java
+++ b/src/jrummikub/control/network/NetworkRoundControl.java
@@ -11,12 +11,22 @@ import jrummikub.view.IView;
public class NetworkRoundControl extends RoundControl {
private IConnectionControl connectionControl;
private boolean currentlyActive;
-
- public NetworkRoundControl(IRoundState roundState, IView view, IConnectionControl connectionControl, boolean startActive) {
+
+ public NetworkRoundControl(IRoundState roundState, IView view,
+ IConnectionControl connectionControl, boolean startActive) {
super(roundState, view);
-
+
this.connectionControl = connectionControl;
currentlyActive = startActive;
+
+ connections.add(connectionControl.getTurnStartEvent().add(
+ new IListener1<IRoundState>() {
+ @Override
+ public void handle(IRoundState state) {
+ NetworkRoundControl.this.roundState = state;
+ startTurn();
+ }
+ }));
}
@Override
@@ -28,7 +38,7 @@ public class NetworkRoundControl extends RoundControl {
}
});
}
-
+
@Override
protected ITurnControl createTurnControl(PlayerSettings playerSettings) {
switch (playerSettings.getType()) {
@@ -39,17 +49,31 @@ public class NetworkRoundControl extends RoundControl {
currentlyActive = false;
break;
}
-
+
if (!currentlyActive) {
return new NetworkTurnControl(connectionControl);
}
-
+
return super.createTurnControl(playerSettings);
}
-
+
@Override
- protected void startTurn() {
- connectionControl.startTurn(roundState);
- super.startTurn();
+ protected void prepareTurn() {
+ boolean wasActive = currentlyActive;
+
+ doPrepareTurn();
+
+ if (wasActive) {
+ connectionControl.startTurn(roundState);
+ }
+ }
+
+ @Override
+ protected void endOfTurn(ITable newTable) {
+ if (currentlyActive) {
+ connectionControl.endTurn(newTable);
+ }
+
+ super.endOfTurn(newTable);
}
}