blob: d053e922c1f83819c4a10782092bf49083aac369 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
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;
/**
* Class controlling network games
*/
public class NetworkGameControl extends GameControl {
private IConnectionControl connectionControl;
private boolean host;
/**
* Creates new network game control
*
* @param gameSettings
* current game settings
* @param saveControl
* if there should ever be saving in network mode
* @param view
* the view
* @param connectionControl
* the current connection
* @param host
* of the current game
*/
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);
}
}
|