summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/tankontank/game/Battle.java4
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleCommon.java23
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleCounterAttack.java36
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleFrontalAssault.java37
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java27
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleLastStand.java34
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleStabToTheFlank.java34
7 files changed, 79 insertions, 116 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Battle.java b/core/src/ch/asynk/tankontank/game/Battle.java
index c2030a0..9b1e502 100644
--- a/core/src/ch/asynk/tankontank/game/Battle.java
+++ b/core/src/ch/asynk/tankontank/game/Battle.java
@@ -11,7 +11,9 @@ public interface Battle
public String getDescription();
- public Player getPlayer(boolean first, boolean deploymentPhase);
+ public Player getPlayer();
+
+ public Player opponent(Player player);
public Map getMap();
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java b/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java
index 9f97eda..3d380d2 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java
@@ -11,6 +11,7 @@ import ch.asynk.tankontank.game.Battle;
import ch.asynk.tankontank.game.Player;
import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.Unit.UnitId;
+import ch.asynk.tankontank.game.State.StateType;
public abstract class BattleCommon implements Battle
{
@@ -53,6 +54,28 @@ public abstract class BattleCommon implements Battle
}
@Override
+ public Player opponent(Player player)
+ {
+ if (player == usPlayer)
+ return gePlayer;
+ return usPlayer;
+ }
+
+ @Override
+ public boolean deploymentDone(Player player)
+ {
+ return player.isDeploymentDone();
+ }
+
+ @Override
+ public StateType getState(Player player)
+ {
+ if (!player.isDeploymentDone())
+ return StateType.DEPLOYMENT;
+ return StateType.SELECT;
+ }
+
+ @Override
public Zone getEntryZone(Unit unit)
{
return unitEntry.get(unit);
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleCounterAttack.java b/core/src/ch/asynk/tankontank/game/battles/BattleCounterAttack.java
index c268ea3..5224d59 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleCounterAttack.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleCounterAttack.java
@@ -35,31 +35,15 @@ public class BattleCounterAttack extends BattleCommon
}
@Override
- public Player getPlayer(boolean first, boolean deploymentPhase)
+ public Player getPlayer()
{
- if (deploymentPhase)
- return (first ? gePlayer : usPlayer);
- else
- return (first ? gePlayer : usPlayer);
- }
-
- @Override
- public StateType getState(Player player)
- {
- if (player.getTurn() == 0)
- return StateType.DEPLOYMENT;
- return StateType.SELECT;
- }
-
- @Override
- public boolean deploymentDone(Player player)
- {
- int n = player.reinforcement();
- if (n == 0) {
- player.deploymentDone();
- return true;
- }
- return false;
+ if (!gePlayer.isDeploymentDone())
+ return gePlayer;
+ if (!usPlayer.isDeploymentDone())
+ return usPlayer;
+ if (gePlayer.getTurnDone() == usPlayer.getTurnDone())
+ return gePlayer;
+ return usPlayer;
}
public Player checkVictory(Ctrl ctrl)
@@ -70,7 +54,7 @@ public class BattleCounterAttack extends BattleCommon
if (gePlayer.escaped() >= 3)
return gePlayer;
- if ((ctrl.player.getTurn() < 9) || (ctrl.opponent.getTurn() < 9))
+ if ((ctrl.player.getTurnDone() < 9) || (ctrl.opponent.getTurnDone() < 9))
return null;
return usPlayer;
@@ -81,7 +65,7 @@ public class BattleCounterAttack extends BattleCommon
{
if (ctrl.player.is(Army.GE))
return false;
- if (ctrl.player.getTurn() != 5)
+ if (ctrl.player.getCurrentTurn() != 5)
return false;
Zone usEntry = new Zone(map, 9);
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleFrontalAssault.java b/core/src/ch/asynk/tankontank/game/battles/BattleFrontalAssault.java
index c9931bc..13483d2 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleFrontalAssault.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleFrontalAssault.java
@@ -29,12 +29,22 @@ public class BattleFrontalAssault extends BattleCommon
}
@Override
- public Player getPlayer(boolean first, boolean deploymentPhase)
+ public Player getPlayer()
{
- if (deploymentPhase)
- return (first ? gePlayer : usPlayer);
- else
- return (first ? usPlayer : gePlayer);
+ if (!gePlayer.isDeploymentDone()) {
+ int n = gePlayer.reinforcement();
+ if (n > 4)
+ return gePlayer;
+ else {
+ if (usPlayer.isDeploymentDone())
+ return gePlayer;
+ else
+ return usPlayer;
+ }
+ }
+ if (gePlayer.getTurnDone() == usPlayer.getTurnDone())
+ return usPlayer;
+ return gePlayer;
}
@Override
@@ -44,22 +54,11 @@ public class BattleFrontalAssault extends BattleCommon
}
@Override
- public StateType getState(Player player)
- {
- if (player.getTurn() == 0)
- return StateType.DEPLOYMENT;
- return StateType.SELECT;
- }
-
- @Override
public boolean deploymentDone(Player player)
{
- int n = player.reinforcement();
- if (n == 0) {
- player.deploymentDone();
+ if (player.isDeploymentDone())
return true;
- }
- return ((player.is(Army.GE) && (n == 4)));
+ return ((player.is(Army.GE) && (gePlayer.reinforcement.size() == 4)));
}
@Override
@@ -68,7 +67,7 @@ public class BattleFrontalAssault extends BattleCommon
if (ctrl.opponent.unitsLeft() == 0)
return ctrl.player;
- if ((ctrl.player.getTurn() < 10) || (ctrl.opponent.getTurn() < 10))
+ if ((ctrl.player.getTurnDone() < 10) || (ctrl.opponent.getTurnDone() < 10))
return null;
int count = 0;
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java b/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java
index 83baeb7..0e3fde7 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java
@@ -32,12 +32,12 @@ public class BattleHeadToHead extends BattleCommon
}
@Override
- public Player getPlayer(boolean first, boolean deploymentPhase)
+ public Player getPlayer()
{
- if (firstArmy == Army.US)
- return (first ? usPlayer : gePlayer);
+ if (gePlayer.getTurnDone() == usPlayer.getTurnDone())
+ return ((firstArmy == Army.US) ? usPlayer : gePlayer);
else
- return (first ? gePlayer : usPlayer);
+ return ((firstArmy == Army.US) ? gePlayer : usPlayer);
}
@Override
@@ -47,24 +47,12 @@ public class BattleHeadToHead extends BattleCommon
}
@Override
- public boolean deploymentDone(Player player)
- {
- return true;
- }
-
- @Override
- public StateType getState(Player player)
- {
- return StateType.SELECT;
- }
-
- @Override
public Player checkVictory(Ctrl ctrl)
{
if (ctrl.opponent.unitsLeft() == 0)
return ctrl.player;
- if ((ctrl.player.getTurn() < 10) || (ctrl.opponent.getTurn() < 10))
+ if ((ctrl.player.getTurnDone() < 10) || (ctrl.opponent.getTurnDone() < 10))
return null;
int player = 0;
@@ -96,8 +84,9 @@ public class BattleHeadToHead extends BattleCommon
@Override
public void setup(Ctrl ctrl, Map map)
{
- gePlayer.deploymentDone();
- usPlayer.deploymentDone();
+ // end deployment
+ usPlayer.turnEnd();
+ gePlayer.turnEnd();
objectives = new TileSet(map, 3);
objectives.add(map.getHex(7, 7));
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleLastStand.java b/core/src/ch/asynk/tankontank/game/battles/BattleLastStand.java
index fc458a6..7adf3e4 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleLastStand.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleLastStand.java
@@ -35,31 +35,15 @@ public class BattleLastStand extends BattleCommon
}
@Override
- public Player getPlayer(boolean first, boolean deploymentPhase)
+ public Player getPlayer()
{
- if (deploymentPhase)
- return (first ? gePlayer : usPlayer);
- else
- return (first ? usPlayer : gePlayer);
- }
-
- @Override
- public StateType getState(Player player)
- {
- if (player.getTurn() == 0)
- return StateType.DEPLOYMENT;
- return StateType.SELECT;
- }
-
- @Override
- public boolean deploymentDone(Player player)
- {
- int n = player.reinforcement();
- if (n == 0) {
- player.deploymentDone();
- return true;
- }
- return false;
+ if (!gePlayer.isDeploymentDone())
+ return gePlayer;
+ if (!usPlayer.isDeploymentDone())
+ return usPlayer;
+ if (gePlayer.getTurnDone() == usPlayer.getTurnDone())
+ return usPlayer;
+ return gePlayer;
}
public Player checkVictory(Ctrl ctrl)
@@ -67,7 +51,7 @@ public class BattleLastStand extends BattleCommon
if (ctrl.opponent.unitsLeft() == 0)
return ctrl.player;
- if ((ctrl.player.getTurn() < 8) || (ctrl.opponent.getTurn() < 8))
+ if ((ctrl.player.getTurnDone() < 8) || (ctrl.opponent.getTurnDone() < 8))
return null;
int gePoints = usPlayer.casualties();
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleStabToTheFlank.java b/core/src/ch/asynk/tankontank/game/battles/BattleStabToTheFlank.java
index 0fed2a3..f251840 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleStabToTheFlank.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleStabToTheFlank.java
@@ -35,31 +35,13 @@ public class BattleStabToTheFlank extends BattleCommon
}
@Override
- public Player getPlayer(boolean first, boolean deploymentPhase)
+ public Player getPlayer()
{
- if (deploymentPhase)
- return (first ? usPlayer : gePlayer);
- else
- return (first ? usPlayer : gePlayer);
- }
-
- @Override
- public StateType getState(Player player)
- {
- if (player.getTurn() == 0)
- return StateType.DEPLOYMENT;
- return StateType.SELECT;
- }
-
- @Override
- public boolean deploymentDone(Player player)
- {
- int n = player.reinforcement();
- if (n == 0) {
- player.deploymentDone();
- return true;
- }
- return false;
+ if (!usPlayer.isDeploymentDone() || usPlayer.getCurrentTurn() == 1)
+ return usPlayer;
+ if (usPlayer.getTurnDone() > gePlayer.getTurnDone())
+ return gePlayer;
+ return usPlayer;
}
public Player checkVictory(Ctrl ctrl)
@@ -67,7 +49,7 @@ public class BattleStabToTheFlank extends BattleCommon
if (ctrl.opponent.unitsLeft() == 0)
return ctrl.player;
- if ((ctrl.player.getTurn() < 9) || (ctrl.opponent.getTurn() < 9))
+ if ((ctrl.player.getTurnDone() < 9) || (ctrl.opponent.getTurnDone() < 9))
return null;
int gePoints = usPlayer.casualties();
@@ -96,7 +78,7 @@ public class BattleStabToTheFlank extends BattleCommon
{
if (ctrl.player.is(Army.US))
return false;
- if (ctrl.player.getTurn() != 3)
+ if (ctrl.player.getCurrentTurn() != 3)
return false;
Zone geEntry = new Zone(map, 9);