From a3e290c95be3a6201ad7c16a88e15719399a1144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sun, 31 Jan 2016 00:31:54 +0100 Subject: Battle: code reorder --- core/src/ch/asynk/rustanddust/game/Battle.java | 4 +- .../rustanddust/game/battles/BattleCommon.java | 52 ++++++++++------------ 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/game/Battle.java b/core/src/ch/asynk/rustanddust/game/Battle.java index 03316bd..6101b37 100644 --- a/core/src/ch/asynk/rustanddust/game/Battle.java +++ b/core/src/ch/asynk/rustanddust/game/Battle.java @@ -13,14 +13,14 @@ public interface Battle public MapType getMapType(); + public Position getHudPosition(); + public void setPlayerIds(int a, int b); public Player getPlayer(); public Player getOpponent(); - public Position getHudPosition(); - public void init(Ctrl ctrl); public boolean actionDone(); diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java index ab7bca4..a6a5c50 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java @@ -106,14 +106,14 @@ public abstract class BattleCommon implements Battle this.currentPlayer = this.usPlayer; setupUS(); map.actionDone(); - currentPlayer.turnEnd(); map.turnDone(); + currentPlayer.turnEnd(); this.currentPlayer = this.gePlayer; setupGE(); map.actionDone(); - currentPlayer.turnEnd(); map.turnDone(); + currentPlayer.turnEnd(); this.currentPlayer = getFirstPlayer(); } @@ -128,6 +128,22 @@ public abstract class BattleCommon implements Battle return burn; } + @Override + public boolean turnDone() + { + map.turnDone(); + currentPlayer.turnEnd(); + Player winner = getWinner(); + if (winner != null) { + currentPlayer = winner; + return true; + } else { + currentPlayer = getOpponent(); + currentPlayer.turnStart(getActionPoints()); + return false; + } + } + protected boolean turnDoneForBoth() { return ((currentPlayer.getTurn() > 0) && (currentPlayer.getTurn() == getOpponent().getTurn())); @@ -157,26 +173,6 @@ public abstract class BattleCommon implements Battle return null; } - @Override - public boolean turnDone() - { - map.turnDone(); - currentPlayer.turnEnd(); - Player winner = getWinner(); - if (winner != null) { - currentPlayer = winner; - return true; - } else { - currentPlayer = getNextPlayer(); - currentPlayer.turnStart(getActionPoints()); - return false; - } - } - - protected Player getNextPlayer() - { - return getOpponent(); - } public void setPlayerIds(int a, int b) { @@ -203,17 +199,17 @@ public abstract class BattleCommon implements Battle } @Override - public StateType getState() + public boolean hasReinforcement() { - if (!currentPlayer.isDeploymentDone()) - return StateType.DEPLOYMENT; - return StateType.SELECT; + return false; } @Override - public boolean hasReinforcement() + public StateType getState() { - return false; + if (!currentPlayer.isDeploymentDone()) + return StateType.DEPLOYMENT; + return StateType.SELECT; } @Override -- cgit v1.1-2-g2b99