diff options
Diffstat (limited to 'src/jrummikub/control/network/ConnectionControl.java')
-rw-r--r-- | src/jrummikub/control/network/ConnectionControl.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/jrummikub/control/network/ConnectionControl.java b/src/jrummikub/control/network/ConnectionControl.java index 832b067..785350e 100644 --- a/src/jrummikub/control/network/ConnectionControl.java +++ b/src/jrummikub/control/network/ConnectionControl.java @@ -107,6 +107,7 @@ public class ConnectionControl implements IConnectionControl { private Event gameStartEvent = new Event(); private Event roundStartEvent = new Event(); + private Event redealEvent = new Event(); private Event1<IRoundState> roundStateUpdateEvent = new Event1<IRoundState>(); private Event1<ITable> tableUpdateEvent = new Event1<ITable>(); @@ -221,6 +222,11 @@ public class ConnectionControl implements IConnectionControl { } @Override + public IEvent getRedealEvent() { + return redealEvent; + } + + @Override public IEvent1<IRoundState> getRoundStateUpdateEvent() { return roundStateUpdateEvent; } @@ -368,6 +374,18 @@ public class ConnectionControl implements IConnectionControl { } @Override + public void redeal() { + final UUID uuid = currentGame.getGameID(); + run(new SendRunner() { + @Override + protected void addData(DefaultPacketExtension extension) { + extension.setValue("messageType", "redeal"); + extension.setValue("uuid", uuid.toString()); + } + }); + } + + @Override public void updateRoundState(final IRoundState roundState) { final UUID uuid = currentGame.getGameID(); run(new SendRunner() { @@ -541,7 +559,16 @@ public class ConnectionControl implements IConnectionControl { gameStartEvent.emit(); } else if (messageType.equals("round_start")) { roundStartEvent.emit(); - } else if (messageType.equals("round_state_update")) { + } else if (messageType.equals("redeal")) { + redealEvent.emit(); + } else { + messagesDuringRound(extension, messageType); + } + } + + private void messagesDuringRound(DefaultPacketExtension extension, + String messageType) { + if (messageType.equals("round_state_update")) { IRoundState state = (IRoundState) Base64.decodeToObject(extension .getValue("state")); fixGameSettings(state.getGameSettings()); |