summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-03-29 19:15:47 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2016-03-29 19:15:47 +0200
commite80f0c920160f5261d07d08ad1b562a9cd020874 (patch)
tree3ebe7b795bd621c448e7e07b62d08f7ec811438c /core
parentc3d2986b22a8f2f1f5afa3567eca9d6b75c9f27a (diff)
downloadRustAndDust-e80f0c920160f5261d07d08ad1b562a9cd020874.zip
RustAndDust-e80f0c920160f5261d07d08ad1b562a9cd020874.tar.gz
Ctrl: knows how to replay a turn
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/rustanddust/game/Ctrl.java37
1 files changed, 31 insertions, 6 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Ctrl.java b/core/src/ch/asynk/rustanddust/game/Ctrl.java
index 4a2c403..bc44fd9 100644
--- a/core/src/ch/asynk/rustanddust/game/Ctrl.java
+++ b/core/src/ch/asynk/rustanddust/game/Ctrl.java
@@ -112,12 +112,24 @@ public abstract class Ctrl implements Disposable
setState(battle.getState());
- if (!synched) {
- map.prepareReplayLastAction();
- setState(StateType.REPLAY);
- } else {
- this.hud.notify(battle.toString(), 2, Position.MIDDLE_CENTER, false);
+ switch(game.config.loadMode) {
+ case REPLAY_ALL:
+ // TODO REPLAY_ALL
+ break;
+ case REPLAY_LAST:
+ map.prepareReplayLastTurn();
+ setState(StateType.REPLAY);
+ break;
+ case LOAD:
+ if (synched) {
+ this.hud.notify(battle.toString(), 2, Position.MIDDLE_CENTER, false);
+ } else {
+ map.prepareReplayLastAction();
+ setState(StateType.REPLAY);
+ }
+ break;
}
+
}
@Override
@@ -269,8 +281,11 @@ public abstract class Ctrl implements Disposable
nextState = completeAction();
}
- if (stateType == StateType.ANIMATION)
+ if (stateType == StateType.ANIMATION) {
this.blockMap = hud.dialogActive();
+ if (nextState == StateType.REPLAY)
+ completeReplay();
+ }
hud.playerInfo.blockEndOfTurn(nextState != StateType.SELECT);
@@ -328,6 +343,16 @@ public abstract class Ctrl implements Disposable
return nextState;
}
+ private void completeReplay()
+ {
+ StateType nextState = replayState.execute();
+
+ if (nextState == StateType.DONE) {
+ battle.getPlayer().burnDownOneAp();
+ hud.update();
+ }
+ }
+
private State getNextState(StateType nextState)
{
RustAndDust.debug("Ctrl", String.format(" %s -> %s : %s", stateType, nextState, battle.getPlayer()));