From e80f0c920160f5261d07d08ad1b562a9cd020874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 29 Mar 2016 19:15:47 +0200 Subject: Ctrl: knows how to replay a turn --- core/src/ch/asynk/rustanddust/game/Ctrl.java | 37 +++++++++++++++++++++++----- 1 file 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())); -- cgit v1.1-2-g2b99