diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-03-14 15:55:11 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-03-14 15:55:11 +0100 |
commit | 3e969f1d7a9966a40657b1ae07b949cde112525b (patch) | |
tree | 96d74c5ce15d8fb1093e61236b75b69bc4f486ea /core/src/ch/asynk/rustanddust/game/battles | |
parent | c3111281e08da0e7e58032f42751a6b1448dbba8 (diff) | |
download | RustAndDust-3e969f1d7a9966a40657b1ae07b949cde112525b.zip RustAndDust-3e969f1d7a9966a40657b1ae07b949cde112525b.tar.gz |
DB/BattleCommon: add turnCount
Diffstat (limited to 'core/src/ch/asynk/rustanddust/game/battles')
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java index 2a4f766..50bb1bd 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java @@ -22,6 +22,7 @@ public abstract class BattleCommon implements Battle protected final Factory factory; protected int _id; + protected int turnCount; protected Factory.MapType mapType; protected String name; protected String description; @@ -67,6 +68,7 @@ public abstract class BattleCommon implements Battle { this.map = factory.getMap(getMapType()); setup(); + this.turnCount = 0; this.currentPlayer = players[0]; } @@ -74,6 +76,7 @@ public abstract class BattleCommon implements Battle public void desinit() { this.map = null; + this.turnCount = 0; this.players[0] = null; this.players[1] = null; this.currentPlayer = null; @@ -95,8 +98,9 @@ public abstract class BattleCommon implements Battle } @Override - public void load(String payload) + public void load(int turn, String payload) { + this.turnCount = turn; map.load(payload, players); this.currentPlayer = players[0]; } @@ -130,13 +134,14 @@ public abstract class BattleCommon implements Battle currentPlayer = getOpponent(); currentPlayer.turnStart(getActionPoints()); } + turnCount += 1; map.turnDone(); return ret; } protected boolean turnDoneForBoth() { - return ((currentPlayer.getTurn() > 0) && (currentPlayer.getTurn() == getOpponent().getTurn())); + return ((turnCount > 0) && ((turnCount % 2) == 0)); } protected Player getWinner(int minTurns) @@ -167,6 +172,12 @@ public abstract class BattleCommon implements Battle } @Override + public int getTurnCount() + { + return turnCount; + } + + @Override public Player getPlayer() { return currentPlayer; |