diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Battle.java | 18 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Ctrl.java | 12 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/battles/BattleCommon.java | 43 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/battles/BattleFake.java | 80 |
4 files changed, 147 insertions, 6 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Battle.java b/core/src/ch/asynk/tankontank/game/Battle.java new file mode 100644 index 0000000..2f13108 --- /dev/null +++ b/core/src/ch/asynk/tankontank/game/Battle.java @@ -0,0 +1,18 @@ +package ch.asynk.tankontank.game; + +public interface Battle +{ + public String getName(); + + public String getDescription(); + + public Map getMap(); + + public Player getFirstPlayer(); + + public Player getSecondPlayer(); + + public void setup(Map map, Player firstPlayer, Player secondPlayer); + + // public boolean checkVictory(Map map, Player player); +} diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java index 480dfae..867e88a 100644 --- a/core/src/ch/asynk/tankontank/game/Ctrl.java +++ b/core/src/ch/asynk/tankontank/game/Ctrl.java @@ -32,17 +32,12 @@ public class Ctrl implements Disposable private State state; - public Ctrl(final TankOnTank game) + public Ctrl(final TankOnTank game, final Battle battle) { this.game = game; this.cfg = game.config; game.ctrl = this; - this.player = game.factory.getPlayer(Army.GE); - this.opponent = game.factory.getPlayer(Army.US); - this.map = game.factory.getMap(Factory.MapType.MAP_A); - game.factory.fakeSetup(map, player, opponent); - this.selectState = new StateSelect(this, map); this.pathState = new StateMove(); this.rotateState = new StateRotate(); @@ -52,6 +47,11 @@ public class Ctrl implements Disposable this.state = selectState; + this.player = battle.getFirstPlayer(); + this.opponent = battle.getSecondPlayer(); + this.map = battle.getMap(); + battle.setup(map, player, opponent); + this.hud = new Hud(this, game); player.turnStart(); diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java b/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java new file mode 100644 index 0000000..ed7a82c --- /dev/null +++ b/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java @@ -0,0 +1,43 @@ +package ch.asynk.tankontank.game.battles; + +import java.util.Random; + +import ch.asynk.tankontank.game.Army; +import ch.asynk.tankontank.game.Battle; + +public abstract class BattleCommon implements Battle +{ + protected final static Random random = new Random(); + + protected String name; + protected String description; + protected Army firstArmy; + protected Army secondArmy; + protected Factory factory; + + public BattleCommon(Factory factory) + { + this.factory = factory; + } + + public String getName() + { + return name; + } + + public String getDescription() + { + return description; + } + + public void randomizeArmies() + { + if (random.nextInt(2) == 0) { + firstArmy = Army.US; + secondArmy = Army.GE; + } else { + firstArmy = Army.GE; + secondArmy = Army.US; + } + } +} diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleFake.java b/core/src/ch/asynk/tankontank/game/battles/BattleFake.java new file mode 100644 index 0000000..19dcec7 --- /dev/null +++ b/core/src/ch/asynk/tankontank/game/battles/BattleFake.java @@ -0,0 +1,80 @@ +package ch.asynk.tankontank.game.battles; + +import java.util.Random; + +import com.badlogic.gdx.math.GridPoint2; + +import ch.asynk.tankontank.game.Map; +import ch.asynk.tankontank.game.Army; +import ch.asynk.tankontank.game.Player; +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(); + } + + @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; + } + Orientation o = Orientation.NORTH; + GridPoint2 p = new GridPoint2(); + + gePlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.GE_TIGER), p.set(4, 7), o)); + gePlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.GE_TIGER), p.set(3, 6), o)); + gePlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.GE_PANZER_IV), p.set(3, 5), o)); + gePlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.GE_PANZER_IV_HQ), p.set(2, 4), o)); + gePlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.GE_PANZER_IV), p.set(2, 3), o)); + gePlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.GE_PANZER_IV), p.set(1, 2), o)); + gePlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.GE_PANZER_IV_HQ), p.set(1, 1), o)); + gePlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.GE_PANZER_IV), p.set(0, 0), o)); + + o = Orientation.SOUTH; + usPlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.US_WOLVERINE), p.set(13, 8), o)); + usPlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.US_WOLVERINE), p.set(12, 7), o)); + usPlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.US_PRIEST), p.set(12, 6), o)); + usPlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.US_SHERMAN), p.set(11, 5), o)); + usPlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.US_SHERMAN_HQ), p.set(11, 4), o)); + usPlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.US_SHERMAN), p.set(10, 3), o)); + usPlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.US_SHERMAN), p.set(10, 2), o)); + usPlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.US_SHERMAN_HQ), p.set(9, 1), o)); + usPlayer.addUnit(map.setPawnAt(factory.getUnit(UnitId.US_SHERMAN), p.set(9, 0), o)); + } + + public boolean checkVictory() + { + return false; + } +} |