From b721725ce99f879681e5b98ceca42f59b0c90818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sun, 2 Nov 2014 16:34:27 +0100 Subject: BattleFake -> BattleHeadToHead --- .../asynk/tankontank/game/battles/BattleFake.java | 109 --------------------- .../tankontank/game/battles/BattleHeadToHead.java | 109 +++++++++++++++++++++ .../ch/asynk/tankontank/screens/GameScreen.java | 4 +- 3 files changed, 111 insertions(+), 111 deletions(-) delete mode 100644 core/src/ch/asynk/tankontank/game/battles/BattleFake.java create mode 100644 core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleFake.java b/core/src/ch/asynk/tankontank/game/battles/BattleFake.java deleted file mode 100644 index 52dd7bd..0000000 --- a/core/src/ch/asynk/tankontank/game/battles/BattleFake.java +++ /dev/null @@ -1,109 +0,0 @@ -package ch.asynk.tankontank.game.battles; - -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; - -public class BattleFake extends BattleCommon -{ - public BattleFake(Factory factory) - { - super(factory); - 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() - { - return factory.getMap(Factory.MapType.MAP_A); - } - - @Override - public Player getFirstPlayer() - { - return factory.getPlayer(firstArmy); - } - - @Override - public Player getSecondPlayer() - { - return factory.getPlayer(secondArmy); - } - - @Override - public void setup(Map map, Player a, Player b) - { - Player gePlayer; - Player usPlayer; - - if (a.isEnemy(Army.GE)) { - usPlayer = a; - gePlayer = b; - } else { - usPlayer = b; - 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.addReinforcement(factory.getUnit(UnitId.GE_TIGER)); - gePlayer.addReinforcement(factory.getUnit(UnitId.GE_TIGER)); - gePlayer.addReinforcement(factory.getUnit(UnitId.GE_PANZER_IV)); - gePlayer.addReinforcement(factory.getUnit(UnitId.GE_PANZER_IV_HQ)); - gePlayer.addReinforcement(factory.getUnit(UnitId.GE_PANZER_IV)); - gePlayer.addReinforcement(factory.getUnit(UnitId.GE_PANZER_IV)); - gePlayer.addReinforcement(factory.getUnit(UnitId.GE_PANZER_IV_HQ)); - gePlayer.addReinforcement(factory.getUnit(UnitId.GE_PANZER_IV)); - - o = Orientation.SOUTH; - usPlayer.addReinforcement(factory.getUnit(UnitId.US_WOLVERINE)); - usPlayer.addReinforcement(factory.getUnit(UnitId.US_WOLVERINE)); - usPlayer.addReinforcement(factory.getUnit(UnitId.US_PRIEST)); - usPlayer.addReinforcement(factory.getUnit(UnitId.US_SHERMAN)); - usPlayer.addReinforcement(factory.getUnit(UnitId.US_SHERMAN_HQ)); - usPlayer.addReinforcement(factory.getUnit(UnitId.US_SHERMAN)); - usPlayer.addReinforcement(factory.getUnit(UnitId.US_SHERMAN)); - usPlayer.addReinforcement(factory.getUnit(UnitId.US_SHERMAN_HQ)); - usPlayer.addReinforcement(factory.getUnit(UnitId.US_SHERMAN)); - } - - public boolean checkVictory() - { - return false; - } -} diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java b/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java new file mode 100644 index 0000000..d6c4af9 --- /dev/null +++ b/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java @@ -0,0 +1,109 @@ +package ch.asynk.tankontank.game.battles; + +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; + +public class BattleHeadToHead extends BattleCommon +{ + public BattleHeadToHead(Factory factory) + { + super(factory); + 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() + { + return factory.getMap(Factory.MapType.MAP_A); + } + + @Override + public Player getFirstPlayer() + { + return factory.getPlayer(firstArmy); + } + + @Override + public Player getSecondPlayer() + { + return factory.getPlayer(secondArmy); + } + + @Override + public void setup(Map map, Player a, Player b) + { + Player gePlayer; + Player usPlayer; + + if (a.isEnemy(Army.GE)) { + usPlayer = a; + gePlayer = b; + } else { + usPlayer = b; + 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.addReinforcement(factory.getUnit(UnitId.GE_TIGER)); + gePlayer.addReinforcement(factory.getUnit(UnitId.GE_TIGER)); + gePlayer.addReinforcement(factory.getUnit(UnitId.GE_PANZER_IV)); + gePlayer.addReinforcement(factory.getUnit(UnitId.GE_PANZER_IV_HQ)); + gePlayer.addReinforcement(factory.getUnit(UnitId.GE_PANZER_IV)); + gePlayer.addReinforcement(factory.getUnit(UnitId.GE_PANZER_IV)); + gePlayer.addReinforcement(factory.getUnit(UnitId.GE_PANZER_IV_HQ)); + gePlayer.addReinforcement(factory.getUnit(UnitId.GE_PANZER_IV)); + + o = Orientation.SOUTH; + usPlayer.addReinforcement(factory.getUnit(UnitId.US_WOLVERINE)); + usPlayer.addReinforcement(factory.getUnit(UnitId.US_WOLVERINE)); + usPlayer.addReinforcement(factory.getUnit(UnitId.US_PRIEST)); + usPlayer.addReinforcement(factory.getUnit(UnitId.US_SHERMAN)); + usPlayer.addReinforcement(factory.getUnit(UnitId.US_SHERMAN_HQ)); + usPlayer.addReinforcement(factory.getUnit(UnitId.US_SHERMAN)); + usPlayer.addReinforcement(factory.getUnit(UnitId.US_SHERMAN)); + usPlayer.addReinforcement(factory.getUnit(UnitId.US_SHERMAN_HQ)); + usPlayer.addReinforcement(factory.getUnit(UnitId.US_SHERMAN)); + } + + public boolean checkVictory() + { + return false; + } +} diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java index 9492509..a139b6c 100644 --- a/core/src/ch/asynk/tankontank/screens/GameScreen.java +++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java @@ -26,7 +26,7 @@ import com.badlogic.gdx.utils.viewport.ScreenViewport; import ch.asynk.tankontank.TankOnTank; import ch.asynk.tankontank.game.Ctrl; -import ch.asynk.tankontank.game.battles.BattleFake; +import ch.asynk.tankontank.game.battles.BattleHeadToHead; public class GameScreen implements Screen { @@ -63,7 +63,7 @@ public class GameScreen implements Screen { this.game = game; - this.ctrl = new Ctrl(game, new BattleFake(game.factory)); + this.ctrl = new Ctrl(game, new BattleHeadToHead(game.factory)); virtualWidth = ctrl.map.getWidth(); virtualHeight = ctrl.map.getHeight(); -- cgit v1.1-2-g2b99