summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-16 13:24:35 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-16 13:24:35 +0100
commitf4d9a5304161e90fefb79b609a4c9469d8fd80e1 (patch)
treee789ea9dd31f418cb36f36630e8f6f8f74fa2862 /core/src
parented4d60b0cb98b0b0442b9ca6a8817a95a88cd4fb (diff)
downloadRustAndDust-f4d9a5304161e90fefb79b609a4c9469d8fd80e1.zip
RustAndDust-f4d9a5304161e90fefb79b609a4c9469d8fd80e1.tar.gz
Ctrl: add deploymentDone() might change player order when both done
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/game/Ctrl.java31
1 files 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()