summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust/game/battles
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk/rustanddust/game/battles')
-rw-r--r--core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java15
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;