summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/network/NetworkTurnControl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control/network/NetworkTurnControl.java')
-rw-r--r--src/jrummikub/control/network/NetworkTurnControl.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/jrummikub/control/network/NetworkTurnControl.java b/src/jrummikub/control/network/NetworkTurnControl.java
new file mode 100644
index 0000000..d80c9b3
--- /dev/null
+++ b/src/jrummikub/control/network/NetworkTurnControl.java
@@ -0,0 +1,53 @@
+package jrummikub.control.network;
+
+import jrummikub.control.turn.AbstractTurnControl;
+import jrummikub.model.IRoundState;
+import jrummikub.model.ITable;
+import jrummikub.util.Event1;
+import jrummikub.util.IEvent1;
+import jrummikub.util.IListener1;
+
+public class NetworkTurnControl extends AbstractTurnControl {
+ private IConnectionControl connectionControl;
+ private Event1<IRoundState> stateUpdateEvent = new Event1<IRoundState>();
+
+
+ public NetworkTurnControl(IConnectionControl connectionControl) {
+ this.connectionControl = connectionControl;
+ }
+
+ public IEvent1<IRoundState> getStateUpdateEvent() {
+ return stateUpdateEvent;
+ }
+
+ @Override
+ public void doStartTurn() {
+ connections.add(connectionControl.getTableUpdateEvent().add(new IListener1<ITable>() {
+ @Override
+ public void handle(ITable table) {
+ view.getTablePanel().setStoneSets(table);
+ }
+ }));
+ connections.add(connectionControl.getTurnEndEvent().add(new IListener1<ITable>() {
+ @Override
+ public void handle(ITable table) {
+ endOfTurn(table);
+ }
+ }));
+
+ timer.startTimer();
+ }
+
+ private void endOfTurn(ITable newTable) {
+ cleanUp();
+ endOfTurnEvent.emit(newTable);
+ }
+
+ @Override
+ protected void timeOut() {
+ }
+
+ @Override
+ protected void pauseTurn() {
+ }
+}