blob: d41034f9a6e9da3f915984566165f4ce8842ff70 (
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 ch.asynk.rustanddust.game.ctrl;
import ch.asynk.rustanddust.RustAndDust;
import ch.asynk.rustanddust.util.Marshal;
import ch.asynk.rustanddust.util.GameRecord;
import ch.asynk.rustanddust.game.Ctrl;
public class Solo extends Ctrl
{
public Solo(final RustAndDust game)
{
super(game);
}
@Override
public void init()
{
if (!loadState()) {
int me = game.backend.getMyId();
int other = game.backend.getOpponentId();
gameId = game.db.storeGameGetId(other, battle.getId(), game.config.gameMode.i);
battle.getPlayer().id = me;
battle.getOpponent().id = other;
battle.initialDeployment(this);
synched = true;
}
}
private boolean loadState()
{
GameRecord r = null;
gameId = game.config.gameId;
switch (game.config.loadMode)
{
case NEW: break;
case RESUME: r = game.db.loadGame(gameId); break;
case REPLAY_LAST: r = game.db.loadLastTurn(gameId); break;
case REPLAY_BATTLE: r = game.db.loadTurn(gameId, 0); break;
}
if (r == null)
return false;
load(Marshal.Mode.MAP, r.map);
load(Marshal.Mode.PLAYERS, r.players);
load(Marshal.Mode.ORDERS, r.orders);
synched = r.synched;
r.dispose();
return true;
}
}
|