diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-12-09 23:20:57 +0100 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-12-09 23:20:57 +0100 | 
| commit | 12e32f31e5b450d5feb2bdf567317604f9a52edc (patch) | |
| tree | 5d832be66b0576d5534451027393386435b29301 /core | |
| parent | fcaca215020060a7830d20d5aa6069dc0e529400 (diff) | |
| download | RustAndDust-12e32f31e5b450d5feb2bdf567317604f9a52edc.zip RustAndDust-12e32f31e5b450d5feb2bdf567317604f9a52edc.tar.gz | |
Ctrl: improve code readability
Diffstat (limited to 'core')
| -rw-r--r-- | core/src/ch/asynk/rustanddust/game/Ctrl.java | 87 | 
1 files changed, 48 insertions, 39 deletions
| diff --git a/core/src/ch/asynk/rustanddust/game/Ctrl.java b/core/src/ch/asynk/rustanddust/game/Ctrl.java index 2b638a6..7dd29d5 100644 --- a/core/src/ch/asynk/rustanddust/game/Ctrl.java +++ b/core/src/ch/asynk/rustanddust/game/Ctrl.java @@ -219,50 +219,14 @@ public class Ctrl implements Disposable                  nextState = completeAction();          } -        if (stateType == StateType.ANIMATION) { +        if (stateType == StateType.ANIMATION)              this.blockMap = hud.dialogActive(); -        } +          hud.playerInfo.blockEndOfTurn(nextState != StateType.SELECT);          this.state.leave(nextState); -        RustAndDust.debug("Ctrl", String.format("  %s -> %s : %s", stateType, nextState, battle.getPlayer())); - -        switch(nextState) { -            case SELECT: -                this.state = selectState; -                break; -            case MOVE: -                this.state = pathState; -                break; -            case ROTATE: -                this.state = rotateState; -                break; -            case PROMOTE: -                this.state = promoteState; -                break; -            case ENGAGE: -                this.state = engageState; -                break; -            case BREAK: -                this.state = breakState; -                break; -            case WITHDRAW: -                this.state = withdrawState; -                break; -            case ANIMATION: -                this.blockMap = true; -                this.state = animationState; -                break; -            case REINFORCEMENT: -                this.state = reinforcementState; -                break; -            case DEPLOYMENT: -                this.state = deploymentState; -                break; -            default: -                break; -        } +        this.state = getNextState(nextState);          StateType tmp = stateType;          stateType = nextState; @@ -304,4 +268,49 @@ public class Ctrl implements Disposable          return nextState;      } + +    private State getNextState(StateType nextState) +    { +        RustAndDust.debug("Ctrl", String.format("  %s -> %s : %s", stateType, nextState, battle.getPlayer())); + +        State state = this.state; + +        switch(nextState) { +            case SELECT: +                state = selectState; +                break; +            case MOVE: +                state = pathState; +                break; +            case ROTATE: +                state = rotateState; +                break; +            case PROMOTE: +                state = promoteState; +                break; +            case ENGAGE: +                state = engageState; +                break; +            case BREAK: +                state = breakState; +                break; +            case WITHDRAW: +                state = withdrawState; +                break; +            case ANIMATION: +                state = animationState; +                this.blockMap = true; +                break; +            case REINFORCEMENT: +                state = reinforcementState; +                break; +            case DEPLOYMENT: +                state = deploymentState; +                break; +            default: +                break; +        } + +        return state; +    }  } | 
