package jrummikub.control.network; import jrummikub.control.RoundControl; import jrummikub.control.turn.ITurnControl; import jrummikub.model.IRoundState; import jrummikub.model.ITable; import jrummikub.model.PlayerSettings; import jrummikub.util.IListener1; 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) { super(roundState, view); this.connectionControl = connectionControl; currentlyActive = startActive; } @Override protected void addTurnControlListeners(ITurnControl turnControl) { turnControl.getTableUpdateEvent().add(new IListener1() { @Override public void handle(ITable table) { connectionControl.updateTable(table); } }); } @Override protected ITurnControl createTurnControl(PlayerSettings playerSettings) { switch (playerSettings.getType()) { case HUMAN: currentlyActive = true; break; case NETWORK: currentlyActive = false; break; } if (!currentlyActive) { return new NetworkTurnControl(connectionControl); } return super.createTurnControl(playerSettings); } @Override protected void startTurn() { connectionControl.startTurn(roundState); super.startTurn(); } }