summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-05-10 14:16:10 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2016-05-10 14:16:16 +0200
commita9adb5d0f27ac64b09d4df660137abac8d6572c9 (patch)
treeb5e2b249940adef9d426a5a7c1848dd44321f5cf /core/src
parent3cbad22ab26755efcb4a2d6e9e8672138b5ab09d (diff)
downloadRustAndDust-a9adb5d0f27ac64b09d4df660137abac8d6572c9.zip
RustAndDust-a9adb5d0f27ac64b09d4df660137abac8d6572c9.tar.gz
Ctrl: implement REPLAY_BATTLE mode
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/rustanddust/game/Ctrl.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Ctrl.java b/core/src/ch/asynk/rustanddust/game/Ctrl.java
index bf944e8..39811d3 100644
--- a/core/src/ch/asynk/rustanddust/game/Ctrl.java
+++ b/core/src/ch/asynk/rustanddust/game/Ctrl.java
@@ -84,6 +84,7 @@ public abstract class Ctrl implements Disposable
private Hex touchedHex;
protected int gameId;
protected boolean synched;
+ private boolean replayBattle;
private int depth;
private Order lastOrder;
@@ -123,12 +124,13 @@ public abstract class Ctrl implements Disposable
this.battle = game.config.battle;
this.hud = new Hud(game);
- this.blockEvents = 0.5f;
+ this.blockEvents = 1.0f;
this.blockMap = true;
this.blockHud = false;
this.touchedHex = null;
this.gameId = -1;
this.synched = false;
+ this.replayBattle = false;
this.depth = 0;
this.lastOrder = null;
@@ -170,7 +172,8 @@ public abstract class Ctrl implements Disposable
this.stateAfterAnimation = StateType.REPLAY;
break;
case REPLAY_BATTLE:
- // TODO REPLAY ALL
+ this.replayBattle = true;
+ map.prepareReplayLastTurn();
this.stateAfterAnimation = StateType.REPLAY;
break;
}
@@ -425,6 +428,24 @@ public abstract class Ctrl implements Disposable
private void replayDone(StateType nextState)
{
if (debugCtrl) RustAndDust.debug(" REPLAY DONE");
+ if (replayBattle) {
+ if (loadTurn(battle.getTurnCount() + 1)) {
+ map.prepareReplayLastTurn();
+ setState(StateType.REPLAY);
+ this.stateAfterAnimation = StateType.REPLAY;
+ } else {
+ hud.notify("Replay Done", Position.MIDDLE_CENTER);
+ map.clearMarshalUnits();
+ if (!synched) {
+ storeGameState();
+ synched = true;
+ }
+ this.mode = Mode.PLAY;
+ checkPlayer(battle.getState());
+ }
+ blockEvents = 0.5f;
+ return;
+ }
hud.notify("Replay Done", Position.MIDDLE_CENTER);
this.mode = Mode.PLAY;
if (nextState != null) {