blob: 969262e640d0f4a80eee76223c55c0bdfc9caf3b (
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
package ch.asynk.rustanddust.game.states;
import ch.asynk.rustanddust.game.Order;
import ch.asynk.rustanddust.game.Ctrl.MsgType;
public class StateReplay extends StateCommon
{
private Order order = null;
@Override
public void enterFrom(StateType prevState)
{
if (this.order != null)
replayStep();
Order o = map.stepReplay();
if (o == null) {
ctrl.postReplayDone(replayDone());
order = null;
} else {
this.order = o;
setup();
ctrl.postOrder(o, StateType.REPLAY);
}
}
private void setup()
{
int s = order.activables.size();
switch (order.type)
{
case MOVE:
select(order.leader);
break;
case ENGAGE:
to = order.engagement.defender.getHex();
break;
case PROMOTE:
default:
break;
}
}
private void replayStep()
{
switch (order.type)
{
case MOVE:
moveReplayStep();
break;
case ENGAGE:
case PROMOTE:
default:
break;
}
}
private void moveReplayStep()
{
switch(order.move.type)
{
case SET:
ctrl.sendMsg(MsgType.UNIT_DEPLOYED, order.move.pawn);
break;
case REGULAR:
case EXIT:
case ENTER:
break;
}
}
private StateType replayDone()
{
if (order == null) return null;
boolean more = (order.activables.size() > 0);
StateType nextState = null;
switch (order.type)
{
case MOVE:
nextState = moveReplayDone(more);
break;
case ENGAGE:
if (more) nextState = StateType.ENGAGE;
break;
case PROMOTE:
default:
break;
}
return nextState;
}
private StateType moveReplayDone(boolean more)
{
StateType nextState = null;
switch(order.move.type)
{
case REGULAR:
case EXIT:
if (more) nextState = StateType.MOVE;
break;
case SET:
nextState = StateType.DEPLOYMENT;
break;
case ENTER:
break;
}
return nextState;
}
}
|