package jrummikub.control.network; import jrummikub.control.GameControl; import jrummikub.control.RoundControl; import jrummikub.control.SaveControl; import jrummikub.model.GameSettings; import jrummikub.model.IRoundState; import jrummikub.util.IListener; import jrummikub.view.IView; import jrummikub.view.IView.BottomPanelType; public class NetworkGameControl extends GameControl { private IConnectionControl connectionControl; private boolean host; public NetworkGameControl(GameSettings gameSettings, SaveControl saveControl, IView view, IConnectionControl connectionControl, boolean host) { super(gameSettings, saveControl, view); this.connectionControl = connectionControl; this.host = host; } @Override protected void startRound() { connections.add(connectionControl.getRoundStartEvent().add(new IListener() { @Override public void handle() { NetworkGameControl.super.startRound(); } })); if (host) { connectionControl.startRound(); } } @Override protected IRoundState createRoundState() { return host ? super.createRoundState() : null; } @Override protected RoundControl createRoundControl(IRoundState roundState) { return new NetworkRoundControl(roundState, view, connectionControl, host); } @Override protected void showWinPanel() { view.setBottomPanel(host ? BottomPanelType.WIN_PANEL : BottomPanelType.NETWORK_WIN_PANEL); } }