diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-01 19:34:18 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-01 19:34:18 +0100 |
commit | fc1d6b90a218fd7072206e6e693e8cd8ac105e2f (patch) | |
tree | a8725e93da8bdbceb92e66b8c6aa01fc8b086333 /core/src/ch/asynk/tankontank/game/battles | |
parent | 4f0fa554282cb32d1b46356acd0a0daeda91c705 (diff) | |
download | RustAndDust-fc1d6b90a218fd7072206e6e693e8cd8ac105e2f.zip RustAndDust-fc1d6b90a218fd7072206e6e693e8cd8ac105e2f.tar.gz |
Battle: add public boolean checkVictory(Ctrl ctrl); and implement it
Diffstat (limited to 'core/src/ch/asynk/tankontank/game/battles')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/battles/BattleFake.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleFake.java b/core/src/ch/asynk/tankontank/game/battles/BattleFake.java index da298c1..fc6e922 100644 --- a/core/src/ch/asynk/tankontank/game/battles/BattleFake.java +++ b/core/src/ch/asynk/tankontank/game/battles/BattleFake.java @@ -4,9 +4,11 @@ import java.util.Random; import com.badlogic.gdx.math.GridPoint2; +import ch.asynk.tankontank.game.Ctrl; import ch.asynk.tankontank.game.Map; import ch.asynk.tankontank.game.Army; import ch.asynk.tankontank.game.Player; +import ch.asynk.tankontank.game.Unit; import ch.asynk.tankontank.game.Unit.UnitId; import ch.asynk.tankontank.engine.Orientation; @@ -18,6 +20,30 @@ public class BattleFake extends BattleCommon randomizeArmies(); } + public boolean checkVictory(Ctrl ctrl) + { + if (ctrl.opponent.unitsLeft() == 0) + return true; + + if ((ctrl.player.getTurn() < 10) || (ctrl.opponent.getTurn() < 10)) + return false; + + Unit unit; + int objectives = 0; + + unit = ctrl.map.getHex(7, 7).getUnit(); + if ((unit != null) && (!ctrl.player.isEnemy(unit))) + objectives += 1; + unit = ctrl.map.getHex(6, 4).getUnit(); + if ((unit != null) && (!ctrl.player.isEnemy(unit))) + objectives += 1; + unit = ctrl.map.getHex(6, 1).getUnit(); + if ((unit != null) && (!ctrl.player.isEnemy(unit))) + objectives += 1; + + return (objectives > 1); + } + @Override public Map getMap() { @@ -50,6 +76,10 @@ public class BattleFake extends BattleCommon gePlayer = a; } + map.showObjective(map.getHex(7, 7)); + map.showObjective(map.getHex(6, 4)); + map.showObjective(map.getHex(6, 1)); + Orientation o = Orientation.NORTH; gePlayer.addUnit(map.setPawnOnto(factory.getUnit(UnitId.GE_TIGER), map.getHex(4, 7), o)); gePlayer.addUnit(map.setPawnOnto(factory.getUnit(UnitId.GE_TIGER), map.getHex(3, 6), o)); |