From f4d9a5304161e90fefb79b609a4c9469d8fd80e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sun, 16 Nov 2014 13:24:35 +0100 Subject: Ctrl: add deploymentDone() might change player order when both done --- core/src/ch/asynk/tankontank/game/Ctrl.java | 31 ++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java index f2d7283..6dc1c44 100644 --- a/core/src/ch/asynk/tankontank/game/Ctrl.java +++ b/core/src/ch/asynk/tankontank/game/Ctrl.java @@ -154,11 +154,6 @@ public class Ctrl implements Disposable { StateType nextState = this.state.done(); - if (stateType == StateType.DEPLOYMENT) { - switchPlayer(); - return nextState; - } - if (nextState == StateType.DONE) { if (map.activatedPawns.size() > 0) { TankOnTank.debug("burn down 1AP"); @@ -175,12 +170,31 @@ public class Ctrl implements Disposable return nextState; } + private StateType deploymentDone() + { + StateType nextState = this.state.done(); + + if (player.isDeploymentDone() && opponent.isDeploymentDone()) { + endPlayerTurn(); + player = battle.getPlayer(true, true); + opponent = battle.getPlayer(false, true); + startPlayerTurn(); + } else + switchPlayer(); + + return nextState; + } + public void setState(StateType nextState) { if (nextState == StateType.ABORT) nextState = actionAborted(); - else if (nextState == StateType.DONE) - nextState = actionDone(); + else if (nextState == StateType.DONE) { + if (stateType == StateType.DEPLOYMENT) + nextState = deploymentDone(); + else + nextState = actionDone(); + } this.state.leave(nextState); @@ -271,8 +285,7 @@ public class Ctrl implements Disposable public void endDeployment() { - state.done(); - switchPlayer(); + deploymentDone(); } public void endGame() -- cgit v1.1-2-g2b99