From 93f3b32f7342b8137baa96186a80ea89dce8ad02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 15 Dec 2015 17:07:00 +0100 Subject: BattleTest: set something like a real battle --- .../asynk/rustanddust/game/battles/BattleTest.java | 113 +++++++++++---------- 1 file changed, 61 insertions(+), 52 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java index 523398d..a9634f6 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java @@ -11,12 +11,10 @@ import ch.asynk.rustanddust.engine.Orientation; public class BattleTest extends BattleCommon { - private Zone usExit; - public BattleTest(Factory factory) { super(factory); - name = "*** Test ***"; + name = "Beta Test"; mapType = Factory.MapType.MAP_00; } @@ -33,32 +31,37 @@ public class BattleTest extends BattleCommon map.turnDone(); usPlayer.turnEnd(); gePlayer.turnEnd(); - currentPlayer = gePlayer; + currentPlayer = usPlayer; } @Override public Player getWinner() { - if (usPlayer.getTurnDone() > 2) + if (!abTurnDone()) + return null; + + if (gePlayer.unitsLeft() == 0) return usPlayer; - return null; + if (usPlayer.unitsLeft() == 0) + return gePlayer; + + if (gePlayer.getTurnDone() <= 8) + return null; + + usPlayer.objectivesWon = map.objectivesCount(Army.US); + gePlayer.objectivesWon = map.objectivesCount(Army.GE); + + if (usPlayer.objectivesWon >= gePlayer.objectivesWon) { + return usPlayer; + } else { + return gePlayer; + } } @Override public boolean hasReinforcement() { - if (currentPlayer.is(Army.GE)) - return false; - if (currentPlayer.getCurrentTurn() != 2) - return false; - - Zone usEntry = new Zone(map, 1); - usEntry.allowedMoves = (Orientation.SOUTH.s | Orientation.SOUTH_EAST.s | Orientation.SOUTH_WEST.s); - usEntry.add(map.getHex(12, 6)); - addEntryZone(usEntry); - addReinforcement(usPlayer, usEntry, usExit, UnitId.US_WOLVERINE); - - return true; + return false; } @Override @@ -66,43 +69,49 @@ public class BattleTest extends BattleCommon { super.setup(); - map.addObjective(5, 2, Army.NONE); - map.addHoldObjective(5, 3, Army.NONE); - map.addObjective(3, 4, Army.NONE); - map.addHoldObjective(3, 3, Army.NONE); - - currentPlayer = gePlayer; - setUnit(map, gePlayer, UnitId.GE_WESPE, 6, 8, Orientation.NORTH, null); - setUnit(map, gePlayer, UnitId.GE_TIGER, 5, 2, Orientation.NORTH, null); - setUnit(map, gePlayer, UnitId.GE_PANZER_IV, 4, 5, Orientation.NORTH_WEST, null); - setUnit(map, gePlayer, UnitId.GE_INFANTRY, 1, 2, Orientation.NORTH_WEST, null); - setUnit(map, gePlayer, UnitId.GE_KINGTIGER, 1, 1, Orientation.NORTH_WEST, null); - - Zone geEntry = new Zone(map, 6); + map.addHoldObjective(5, 2, Army.NONE); + map.addObjective(11, 7, Army.US); + + Zone usEntry = new Zone(map, 10); + usEntry.orientation = Orientation.SOUTH; + usEntry.add(map.getHex(8, 0)); + usEntry.add(map.getHex(9, 0)); + usEntry.add(map.getHex(8, 1)); + usEntry.add(map.getHex(9, 1)); + usEntry.add(map.getHex(9, 2)); + usEntry.add(map.getHex(10, 2)); + usEntry.add(map.getHex(9, 3)); + usEntry.add(map.getHex(10, 3)); + usEntry.add(map.getHex(10, 4)); + usEntry.add(map.getHex(11, 4)); + addEntryZone(usEntry); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN, true, false); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_WOLVERINE, true, false); + addReinforcement(usPlayer, usEntry, UnitId.US_WOLVERINE); + addReinforcement(usPlayer, usEntry, UnitId.US_PERSHING); + addReinforcement(usPlayer, usEntry, UnitId.US_PRIEST); + + Zone geEntry = new Zone(map, 8); geEntry.orientation = Orientation.NORTH; - geEntry.add(map.getHex(1, 2)); - geEntry.add(map.getHex(1, 1)); - geEntry.add(map.getHex(3, 3)); - geEntry.add(map.getHex(3, 4)); + geEntry.add(map.getHex(4, 8)); + geEntry.add(map.getHex(5, 8)); + geEntry.add(map.getHex(4, 7)); + geEntry.add(map.getHex(5, 7)); + geEntry.add(map.getHex(3, 6)); + geEntry.add(map.getHex(4, 6)); + geEntry.add(map.getHex(3, 5)); + geEntry.add(map.getHex(4, 5)); addEntryZone(geEntry); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV, true, false); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_TIGER); + addReinforcement(gePlayer, geEntry, UnitId.GE_WESPE); + addReinforcement(gePlayer, geEntry, UnitId.GE_AT_GUN); addReinforcement(gePlayer, geEntry, UnitId.GE_AT_GUN); - - usExit = new Zone(map, 9); - usExit.orientation = Orientation.NORTH; - usExit.add(map.getHex(11, 4)); - usExit.add(map.getHex(11, 5)); - usExit.add(map.getHex(12, 6)); - addExitZone(usExit); - - currentPlayer = usPlayer; - usPlayer.casualty(factory.getUnit(UnitId.US_SHERMAN, true, false)); - setUnit(map, usPlayer, UnitId.US_PRIEST, 7, 6, Orientation.SOUTH_EAST, usExit); - setUnit(map, usPlayer, UnitId.US_SHERMAN, 8, 4, Orientation.SOUTH, false, true, usExit); - setUnit(map, usPlayer, UnitId.US_SHERMAN, 7, 3, Orientation.SOUTH, true, false, usExit); - setUnit(map, usPlayer, UnitId.US_WOLVERINE, 11, 7, Orientation.SOUTH_EAST, usExit); - setUnit(map, usPlayer, UnitId.US_PERSHING, 6, 5, Orientation.SOUTH, usExit); - setUnit(map, usPlayer, UnitId.US_INFANTRY, 5, 3, Orientation.NORTH_EAST, usExit); - setUnit(map, usPlayer, UnitId.US_AT_GUN, 6, 1, Orientation.SOUTH, usExit); return this.map; } -- cgit v1.1-2-g2b99