blob: d80c9b327bea4e25893a3ee54901bff78ce7f389 (
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
|
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() {
}
}
|