diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-22 15:37:40 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-22 15:37:40 +0100 |
commit | 5b3b354bd3d39b4193a0a067d76fe46fe42106ee (patch) | |
tree | 4fcbc9c38001ec6310e5985c22aa0e85a4e5638a /core | |
parent | fdc5e6401c4452a8fdb5aff253f9c806ab011941 (diff) | |
download | RustAndDust-5b3b354bd3d39b4193a0a067d76fe46fe42106ee.zip RustAndDust-5b3b354bd3d39b4193a0a067d76fe46fe42106ee.tar.gz |
Solo: supports battle reloading
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/ctrl/Solo.java | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java b/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java index 1a7a0af..bcafe29 100644 --- a/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java +++ b/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java @@ -6,6 +6,8 @@ import ch.asynk.rustanddust.game.Battle; public class Solo extends Ctrl { + private int gameId; + public Solo(final RustAndDust game, final Battle battle) { super(game, battle); @@ -14,12 +16,32 @@ public class Solo extends Ctrl @Override public void init() { - battle.init(this, 0, 1); + gameId = game.config.gameId; + if (gameId == game.db.NO_RECORDS) { + int me = game.backend.getMyId(); + int other = game.backend.getOpponentId(); + gameId = game.db.storeGameGetId(me, other, battle.getId(), game.config.gameMode.i); + battle.init(this, me, other); + } else { + battle.init(this, game.db.loadState(gameId)); + } } @Override - protected void processAction() { } + protected void processAction() + { + storeState(); + } @Override - protected void processTurn() { } + protected void processTurn() + { + // TODO must store Orders in turns table + storeState(); + } + + private void storeState() + { + game.db.storeState(gameId, battle.getPlayer().getId(), battle.getOpponent().getId(), battle.unload()); + } } |