diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-11-21 13:53:18 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-11-21 13:53:18 +0100 |
commit | 5ec3bec813d29e2d669fd7579111ec731ce55b09 (patch) | |
tree | ea20f0f0736cbf784bec738866885307ecb289a3 /old | |
parent | c2a6dee4769dda9d72c86d6b66af49cf420e6dde (diff) | |
download | RustAndDust-5ec3bec813d29e2d669fd7579111ec731ce55b09.zip RustAndDust-5ec3bec813d29e2d669fd7579111ec731ce55b09.tar.gz |
remove LNL battles, and map definitions
Diffstat (limited to 'old')
-rw-r--r-- | old/BattleCounterAttack.java | 150 | ||||
-rw-r--r-- | old/BattleFrontalAssault.java | 124 | ||||
-rw-r--r-- | old/BattleHeadToHead.java | 118 | ||||
-rw-r--r-- | old/BattleLastStand.java | 136 | ||||
-rw-r--r-- | old/BattleNightAction.java | 153 | ||||
-rw-r--r-- | old/BattleStabToTheFlank.java | 143 | ||||
-rw-r--r-- | old/MapA.java | 95 | ||||
-rw-r--r-- | old/MapB.java | 93 |
8 files changed, 1012 insertions, 0 deletions
diff --git a/old/BattleCounterAttack.java b/old/BattleCounterAttack.java new file mode 100644 index 0000000..cea1d13 --- /dev/null +++ b/old/BattleCounterAttack.java @@ -0,0 +1,150 @@ +package ch.asynk.rustanddust.game.battles; + +import ch.asynk.rustanddust.game.Army; +import ch.asynk.rustanddust.game.Player; +import ch.asynk.rustanddust.game.Ctrl; +import ch.asynk.rustanddust.game.Map; +import ch.asynk.rustanddust.game.Zone; +import ch.asynk.rustanddust.game.Unit; +import ch.asynk.rustanddust.game.Unit.UnitId; +import ch.asynk.rustanddust.ui.Position; +import ch.asynk.rustanddust.engine.Orientation; + +public class BattleCounterAttack extends BattleCommon +{ + public BattleCounterAttack(Factory factory) + { + super(factory); + name = "Counterattack"; + mapType = Factory.MapType.MAP_B; + } + + @Override + public Position getHudPosition(Player player) + { + return (player.is(Army.US) ? Position.TOP_RIGHT: Position.TOP_LEFT); + } + + @Override + public Player getPlayer() + { + if (!gePlayer.isDeploymentDone()) + return gePlayer; + if (!usPlayer.isDeploymentDone()) + return usPlayer; + if (gePlayer.getTurnDone() == usPlayer.getTurnDone()) + return gePlayer; + return usPlayer; + } + + public Player checkVictory(Ctrl ctrl) + { + if (ctrl.opponent.unitsLeft() == 0) + return ctrl.player; + + if (gePlayer.withdrawed() >= 3) + return gePlayer; + + if ((ctrl.player.getTurnDone() < 9) || (ctrl.opponent.getTurnDone() < 9)) + return null; + + return usPlayer; + } + + @Override + public boolean getReinforcement(Ctrl ctrl, Map map) + { + if (ctrl.player.is(Army.GE)) + return false; + if (ctrl.player.getCurrentTurn() != 5) + return false; + + // hex row 1 + Zone usEntry = new Zone(map, 9); + usEntry.allowedMoves = (Orientation.SOUTH.s | Orientation.SOUTH_EAST.s | Orientation.SOUTH_WEST.s); + usEntry.add(map.getHex(9, 0)); + usEntry.add(map.getHex(9, 1)); + usEntry.add(map.getHex(10, 2)); + usEntry.add(map.getHex(10, 3)); + usEntry.add(map.getHex(11, 4)); + usEntry.add(map.getHex(11, 5)); + usEntry.add(map.getHex(12, 6)); + usEntry.add(map.getHex(12, 7)); + usEntry.add(map.getHex(13, 8)); + addEntryZone(usEntry); + + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_PRIEST); + + return true; + } + + @Override + public void setup(Ctrl ctrl, Map map) + { + // hex row 1 + Zone geExit = new Zone(map, 9); + geExit.orientation = Orientation.NORTH; + geExit.add(map.getHex(9, 0)); + geExit.add(map.getHex(9, 1)); + geExit.add(map.getHex(10, 2)); + geExit.add(map.getHex(10, 3)); + geExit.add(map.getHex(11, 4)); + geExit.add(map.getHex(11, 5)); + geExit.add(map.getHex(12, 6)); + geExit.add(map.getHex(12, 7)); + geExit.add(map.getHex(13, 8)); + addExitZone(geExit); + + // hex rows 8-9 + Zone geEntry = new Zone(map, 18); + geEntry.orientation = Orientation.NORTH; + for (int i = 0; i < 2; i++) { + geEntry.add(map.getHex((1 + i), 0)); + geEntry.add(map.getHex((1 + i), 1)); + geEntry.add(map.getHex((2 + i), 2)); + geEntry.add(map.getHex((2 + i), 3)); + geEntry.add(map.getHex((3 + i), 4)); + geEntry.add(map.getHex((3 + i), 5)); + geEntry.add(map.getHex((4 + i), 6)); + geEntry.add(map.getHex((4 + i), 7)); + geEntry.add(map.getHex((5 + i), 8)); + } + addEntryZone(geEntry); + + addReinforcement(gePlayer, geEntry, geExit, UnitId.GE_PANZER_IV_HQ); + addReinforcement(gePlayer, geEntry, geExit, UnitId.GE_PANZER_IV_HQ); + addReinforcement(gePlayer, geEntry, geExit, UnitId.GE_TIGER); + addReinforcement(gePlayer, geEntry, geExit, UnitId.GE_TIGER); + addReinforcement(gePlayer, geEntry, geExit, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, geExit, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, geExit, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, geExit, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, geExit, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, geExit, UnitId.GE_WESPE); + + // hex rows 1-4 + Zone usEntry = new Zone(map, 36); + usEntry.orientation = Orientation.SOUTH; + for (int i = 0; i < 4; i++) { + usEntry.add(map.getHex((6 + i), 0)); + usEntry.add(map.getHex((6 + i), 1)); + usEntry.add(map.getHex((7 + i), 2)); + usEntry.add(map.getHex((7 + i), 3)); + usEntry.add(map.getHex((8 + i), 4)); + usEntry.add(map.getHex((8 + i), 5)); + usEntry.add(map.getHex((9 + i), 6)); + usEntry.add(map.getHex((9 + i), 7)); + usEntry.add(map.getHex((10 + i), 8)); + } + addEntryZone(usEntry); + + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN_HQ); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN_HQ); + addReinforcement(usPlayer, usEntry, UnitId.US_WOLVERINE); + addReinforcement(usPlayer, usEntry, UnitId.US_WOLVERINE); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + } +} diff --git a/old/BattleFrontalAssault.java b/old/BattleFrontalAssault.java new file mode 100644 index 0000000..372e045 --- /dev/null +++ b/old/BattleFrontalAssault.java @@ -0,0 +1,124 @@ +package ch.asynk.rustanddust.game.battles; + +import ch.asynk.rustanddust.game.Army; +import ch.asynk.rustanddust.game.Player; +import ch.asynk.rustanddust.game.Ctrl; +import ch.asynk.rustanddust.game.Map; +import ch.asynk.rustanddust.game.Hex; +import ch.asynk.rustanddust.game.HexSet; +import ch.asynk.rustanddust.game.Zone; +import ch.asynk.rustanddust.game.Unit; +import ch.asynk.rustanddust.game.Unit.UnitId; +import ch.asynk.rustanddust.ui.Position; +import ch.asynk.rustanddust.engine.Orientation; + +public class BattleFrontalAssault extends BattleCommon +{ + public BattleFrontalAssault(Factory factory) + { + super(factory); + name = "Frontal Assault"; + mapType = Factory.MapType.MAP_A; + } + + + @Override + public Player getPlayer() + { + 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 + public Position getHudPosition(Player player) + { + return (player.is(Army.US) ? Position.TOP_RIGHT: Position.TOP_LEFT); + } + + @Override + public boolean deploymentDone(Player player) + { + if (player.isDeploymentDone()) + return true; + return ((player.is(Army.GE) && (gePlayer.reinforcement.size() == 4))); + } + + @Override + public Player checkVictory(Ctrl ctrl) + { + if (ctrl.opponent.unitsLeft() == 0) + return ctrl.player; + + if ((ctrl.player.getTurnDone() < 10) || (ctrl.opponent.getTurnDone() < 10)) + return null; + + if (ctrl.map.objectives.count(Army.US) >= 2) + return usPlayer; + else + return gePlayer; + } + + @Override + public void setup(Ctrl ctrl, Map map) + { + // G9, E6, H4 + map.addObjective(2, 2, Army.NONE); + map.addObjective(6, 4, Army.NONE); + map.addObjective(6, 1, Army.NONE); + + // hex rows E-H + Zone geEntry = new Zone(map, 38); + geEntry.orientation = Orientation.NORTH_WEST; + for (int i = 2; i < 12; i++) + geEntry.add(map.getHex(i, 4)); + for (int i = 2; i < 11; i++) + geEntry.add(map.getHex(i, 3)); + for (int i = 1; i < 11; i++) + geEntry.add(map.getHex(i, 2)); + for (int i = 1; i < 10; i++) + geEntry.add(map.getHex(i, 1)); + addEntryZone(geEntry); + + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV_HQ); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV_HQ); + addReinforcement(gePlayer, geEntry, UnitId.GE_TIGER); + addReinforcement(gePlayer, geEntry, UnitId.GE_TIGER); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + + // hex rows A-B + Zone usEntry = new Zone(map, 19); + usEntry.orientation = Orientation.SOUTH_EAST; + for (int i = 4; i < 14; i++) + usEntry.add(map.getHex(i, 8)); + for (int i = 4; i < 13; i++) + usEntry.add(map.getHex(i, 7)); + addEntryZone(usEntry); + + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN_HQ); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN_HQ); + addReinforcement(usPlayer, usEntry, UnitId.US_WOLVERINE); + addReinforcement(usPlayer, usEntry, UnitId.US_WOLVERINE); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_PRIEST); + } +} diff --git a/old/BattleHeadToHead.java b/old/BattleHeadToHead.java new file mode 100644 index 0000000..0d88846 --- /dev/null +++ b/old/BattleHeadToHead.java @@ -0,0 +1,118 @@ +package ch.asynk.rustanddust.game.battles; + +import ch.asynk.rustanddust.game.Zone; +import ch.asynk.rustanddust.game.Army; +import ch.asynk.rustanddust.game.Player; +import ch.asynk.rustanddust.game.Ctrl; +import ch.asynk.rustanddust.game.Map; +import ch.asynk.rustanddust.game.Hex; +import ch.asynk.rustanddust.game.HexSet; +import ch.asynk.rustanddust.game.Unit; +import ch.asynk.rustanddust.game.Unit.UnitId; +import ch.asynk.rustanddust.ui.Position; +import ch.asynk.rustanddust.engine.Orientation; + +public class BattleHeadToHead extends BattleCommon +{ + private Army firstArmy; + + public BattleHeadToHead(Factory factory) + { + super(factory); + name = "Head To Head"; + firstArmy = ((random.nextInt(2) == 0) ? Army.US : Army.GE); + mapType = Factory.MapType.MAP_A; + } + + @Override + public Player getPlayer() + { + if (gePlayer.getTurnDone() == usPlayer.getTurnDone()) + return ((firstArmy == Army.US) ? usPlayer : gePlayer); + else + return ((firstArmy == Army.US) ? gePlayer : usPlayer); + } + + @Override + public Position getHudPosition(Player player) + { + return (player.is(Army.US) ? Position.TOP_RIGHT: Position.TOP_LEFT); + } + + @Override + public Player checkVictory(Ctrl ctrl) + { + if (ctrl.opponent.unitsLeft() == 0) + return ctrl.player; + + if ((ctrl.player.getTurnDone() < 10) || (ctrl.opponent.getTurnDone() < 10)) + return null; + + if (ctrl.map.objectives.count(Army.US) >= 2) + return usPlayer; + if (ctrl.map.objectives.count(Army.GE) >= 2) + return gePlayer; + + return null; + } + + @Override + public void setup(Ctrl ctrl, Map map) + { + // end deployment + usPlayer.turnEnd(); + gePlayer.turnEnd(); + + // B6, E6, H4 + map.addObjective(7, 7, Army.NONE); + map.addObjective(6, 4, Army.NONE); + map.addObjective(6, 1, Army.NONE); + + // southern hex row + Zone geEntry = new Zone(map, 9); + geEntry.allowedMoves = (Orientation.NORTH.s | Orientation.NORTH_EAST.s | Orientation.NORTH_WEST.s); + geEntry.add(map.getHex(0, 0)); + geEntry.add(map.getHex(1, 1)); + geEntry.add(map.getHex(1, 2)); + geEntry.add(map.getHex(2, 3)); + geEntry.add(map.getHex(2, 4)); + geEntry.add(map.getHex(3, 5)); + geEntry.add(map.getHex(3, 6)); + geEntry.add(map.getHex(4, 7)); + geEntry.add(map.getHex(4, 8)); + addEntryZone(geEntry); + + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV_HQ); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV_HQ); + addReinforcement(gePlayer, geEntry, UnitId.GE_TIGER); + addReinforcement(gePlayer, geEntry, UnitId.GE_TIGER); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + + // northern hex row + Zone usEntry = new Zone(map, 9); + usEntry.allowedMoves = (Orientation.SOUTH.s | Orientation.SOUTH_EAST.s | Orientation.SOUTH_WEST.s); + usEntry.add(map.getHex(9, 0)); + usEntry.add(map.getHex(9, 1)); + usEntry.add(map.getHex(10, 2)); + usEntry.add(map.getHex(10, 3)); + usEntry.add(map.getHex(11, 4)); + usEntry.add(map.getHex(11, 5)); + usEntry.add(map.getHex(12, 6)); + usEntry.add(map.getHex(12, 7)); + usEntry.add(map.getHex(13, 8)); + addEntryZone(usEntry); + + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN_HQ); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN_HQ); + addReinforcement(usPlayer, usEntry, UnitId.US_WOLVERINE); + addReinforcement(usPlayer, usEntry, UnitId.US_WOLVERINE); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_PRIEST); + } +} diff --git a/old/BattleLastStand.java b/old/BattleLastStand.java new file mode 100644 index 0000000..f898ce9 --- /dev/null +++ b/old/BattleLastStand.java @@ -0,0 +1,136 @@ +package ch.asynk.rustanddust.game.battles; + +import ch.asynk.rustanddust.game.Zone; +import ch.asynk.rustanddust.game.Army; +import ch.asynk.rustanddust.game.Player; +import ch.asynk.rustanddust.game.Ctrl; +import ch.asynk.rustanddust.game.Map; +import ch.asynk.rustanddust.game.Hex; +import ch.asynk.rustanddust.game.HexSet; +import ch.asynk.rustanddust.game.Unit; +import ch.asynk.rustanddust.game.Unit.UnitId; +import ch.asynk.rustanddust.ui.Position; +import ch.asynk.rustanddust.engine.Orientation; + +public class BattleLastStand extends BattleCommon +{ + public BattleLastStand(Factory factory) + { + super(factory); + name = "Last Stand"; + mapType = Factory.MapType.MAP_B; + } + + @Override + public Position getHudPosition(Player player) + { + return (player.is(Army.US) ? Position.TOP_RIGHT: Position.TOP_LEFT); + } + + @Override + public Player getPlayer() + { + if (!gePlayer.isDeploymentDone()) + return gePlayer; + if (!usPlayer.isDeploymentDone()) + return usPlayer; + if (gePlayer.getTurnDone() == usPlayer.getTurnDone()) + return usPlayer; + return gePlayer; + } + + public Player checkVictory(Ctrl ctrl) + { + if (ctrl.opponent.unitsLeft() == 0) + return ctrl.player; + + if ((ctrl.player.getTurnDone() < 8) || (ctrl.opponent.getTurnDone() < 8)) + return null; + + int gePoints = usPlayer.casualties(); + int usPoints = gePlayer.casualties(); + usPoints += ctrl.map.objectives.count(Army.US); + for (Unit unit : gePlayer.casualties) { + if (unit.isAce()) + usPoints += 1; + } + + if (usPoints > gePoints) + return usPlayer; + else + return gePlayer; + } + + @Override + public void setup(Ctrl ctrl, Map map) + { + // A7, E6, F6, G10 + map.addObjective(7, 8, Army.NONE); + map.addObjective(6, 4, Army.NONE); + map.addObjective(5, 3, Army.NONE); + map.addObjective(1, 2, Army.NONE); + + // 1 hex of E7 + Zone geEntry = new Zone(map, 7); + geEntry.orientation = Orientation.NORTH; + geEntry.add(map.getHex(5, 5)); + geEntry.add(map.getHex(4, 4)); + geEntry.add(map.getHex(4, 3)); + geEntry.add(map.getHex(5, 3)); + geEntry.add(map.getHex(6, 4)); + geEntry.add(map.getHex(6, 5)); + geEntry.add(map.getHex(5, 4)); + addEntryZone(geEntry); + + addReinforcement(gePlayer, geEntry, UnitId.GE_TIGER, true); + addReinforcement(gePlayer, geEntry, UnitId.GE_TIGER); + addReinforcement(gePlayer, geEntry, UnitId.GE_TIGER); + + // hex rows 7-10 + geEntry = new Zone(map, 32); + geEntry.orientation = Orientation.NORTH; + for (int i = 0; i < 4; i++) { + geEntry.add(map.getHex(i, 0)); + geEntry.add(map.getHex((i + 1), 2)); + geEntry.add(map.getHex((i + 2), 4)); + geEntry.add(map.getHex((i + 3), 6)); + geEntry.add(map.getHex((i + 4), 8)); + } + for (int i = 0; i < 3; i++) { + geEntry.add(map.getHex((i + 1), 1)); + geEntry.add(map.getHex((i + 2), 3)); + geEntry.add(map.getHex((i + 3), 5)); + geEntry.add(map.getHex((i + 4), 7)); + } + addEntryZone(geEntry); + + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_WESPE); + + // hex rows hex row 1 + E2 + C2 + Zone usEntry = new Zone(map, 11); + usEntry.orientation = Orientation.SOUTH; + usEntry.add(map.getHex(9, 0)); + usEntry.add(map.getHex(9, 1)); + usEntry.add(map.getHex(10, 2)); + usEntry.add(map.getHex(10, 3)); + usEntry.add(map.getHex(11, 4)); + usEntry.add(map.getHex(11, 5)); + usEntry.add(map.getHex(12, 6)); + usEntry.add(map.getHex(12, 7)); + usEntry.add(map.getHex(13, 8)); + usEntry.add(map.getHex(10, 4)); + usEntry.add(map.getHex(11, 6)); + addEntryZone(usEntry); + + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN_HQ); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN_HQ); + addReinforcement(usPlayer, usEntry, UnitId.US_WOLVERINE); + addReinforcement(usPlayer, usEntry, UnitId.US_WOLVERINE); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + } +} diff --git a/old/BattleNightAction.java b/old/BattleNightAction.java new file mode 100644 index 0000000..f9817db --- /dev/null +++ b/old/BattleNightAction.java @@ -0,0 +1,153 @@ +package ch.asynk.rustanddust.game.battles; + +import ch.asynk.rustanddust.game.Zone; +import ch.asynk.rustanddust.game.Army; +import ch.asynk.rustanddust.game.Player; +import ch.asynk.rustanddust.game.Ctrl; +import ch.asynk.rustanddust.game.Map; +import ch.asynk.rustanddust.game.Hex; +import ch.asynk.rustanddust.game.HexSet; +import ch.asynk.rustanddust.game.Unit; +import ch.asynk.rustanddust.game.Unit.UnitId; +import ch.asynk.rustanddust.ui.Position; +import ch.asynk.rustanddust.engine.Orientation; +import ch.asynk.rustanddust.engine.Meteorology; + +public class BattleNightAction extends BattleCommon +{ + public BattleNightAction(Factory factory) + { + super(factory); + name = "Night Action"; + mapType = Factory.MapType.MAP_B; + } + + @Override + public Position getHudPosition(Player player) + { + return (player.is(Army.US) ? Position.TOP_RIGHT: Position.TOP_LEFT); + } + + @Override + public Player getPlayer() + { + if (!gePlayer.isDeploymentDone() || gePlayer.getCurrentTurn() == 1) + return gePlayer; + if (gePlayer.getTurnDone() > usPlayer.getTurnDone()) + return usPlayer; + return gePlayer; + } + + private boolean isClear(Map map, int col, int row) + { + Hex hex = map.getHex(col, row); + Unit unit = hex.getUnit(); + if ((unit != null) && unit.is(Army.GE)) { + map.selectHex(hex); + return false; + } + map.showMove(hex); + return true; + } + + public Player checkVictory(Ctrl ctrl) + { + if (ctrl.opponent.unitsLeft() == 0) + return ctrl.player; + + if ((ctrl.player.getTurnDone() < 9) || (ctrl.opponent.getTurnDone() < 9)) + return null; + + Map map = ctrl.map; + boolean clear = true; + clear &= isClear(map, 4, 8); + clear &= isClear(map, 5, 8); + clear &= isClear(map, 6, 8); + clear &= isClear(map, 7, 8); + clear &= isClear(map, 8, 8); + clear &= isClear(map, 8, 7); + clear &= isClear(map, 8, 6); + boolean upLeft = clear; + clear = true; + clear &= isClear(map, 8, 6); + clear &= isClear(map, 9, 6); + clear &= isClear(map, 10, 6); + clear &= isClear(map, 11, 6); + clear &= isClear(map, 12, 6); + boolean upRight = clear; + clear = true; + clear &= isClear(map, 1, 2); + clear &= isClear(map, 2, 3); + clear &= isClear(map, 3, 3); + clear &= isClear(map, 4, 3); + clear &= isClear(map, 5, 3); + clear &= isClear(map, 6, 4); + clear &= isClear(map, 7, 4); + clear &= isClear(map, 8, 4); + boolean bottomLeft = clear; + clear &= isClear(map, 8, 4); + clear &= isClear(map, 9, 4); + clear &= isClear(map, 10, 4); + clear &= isClear(map, 11, 4); + clear = true; + boolean bottomRight = clear; + // clear &= isClear(map, 8, 6); + // clear &= isClear(map, 8, 5); + // clear &= isClear(map, 8, 4); + // clear = true; + // boolean link = clear; + + if ((!upLeft || !upRight) && (!bottomLeft || !bottomRight)) + return gePlayer; + return usPlayer; + } + + @Override + public void setup(Ctrl ctrl, Map map) + { + map.meteorology.day = Meteorology.Day.NIGHT; + + // hex row I + Zone geEntry = new Zone(map, 10); + geEntry.orientation = Orientation.NORTH_EAST; + for (int i = 0; i < 10; i++) + geEntry.add(map.getHex(i, 0)); + addEntryZone(geEntry); + + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV_HQ); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV_HQ); + addReinforcement(gePlayer, geEntry, UnitId.GE_TIGER); + addReinforcement(gePlayer, geEntry, UnitId.GE_TIGER); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_INFANTRY); + addReinforcement(gePlayer, geEntry, UnitId.GE_INFANTRY); + + // hex rows A-B + Zone usEntry = new Zone(map, 19); + usEntry.orientation = Orientation.SOUTH; + for (int i = 0; i < 10; i++) { + usEntry.add(map.getHex((4 + i), 8)); + usEntry.add(map.getHex((3 + i), 6)); + usEntry.add(map.getHex((2 + i), 4)); + usEntry.add(map.getHex((1 + i), 2)); + } + for (int i = 0; i < 9; i++) { + usEntry.add(map.getHex((4 + i), 7)); + usEntry.add(map.getHex((3 + i), 5)); + usEntry.add(map.getHex((2 + i), 3)); + } + addEntryZone(usEntry); + + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN_HQ); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN_HQ); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, UnitId.US_WOLVERINE); + addReinforcement(usPlayer, usEntry, UnitId.US_AT_GUN); + addReinforcement(usPlayer, usEntry, UnitId.US_INFANTRY); + addReinforcement(usPlayer, usEntry, UnitId.US_INFANTRY); + } +} diff --git a/old/BattleStabToTheFlank.java b/old/BattleStabToTheFlank.java new file mode 100644 index 0000000..c45bac4 --- /dev/null +++ b/old/BattleStabToTheFlank.java @@ -0,0 +1,143 @@ +package ch.asynk.rustanddust.game.battles; + +import ch.asynk.rustanddust.game.Zone; +import ch.asynk.rustanddust.game.Army; +import ch.asynk.rustanddust.game.Player; +import ch.asynk.rustanddust.game.Ctrl; +import ch.asynk.rustanddust.game.Map; +import ch.asynk.rustanddust.game.Hex; +import ch.asynk.rustanddust.game.HexSet; +import ch.asynk.rustanddust.game.Unit; +import ch.asynk.rustanddust.game.Unit.UnitId; +import ch.asynk.rustanddust.ui.Position; +import ch.asynk.rustanddust.engine.Orientation; + +public class BattleStabToTheFlank extends BattleCommon +{ + public BattleStabToTheFlank(Factory factory) + { + super(factory); + name = "Stab To The Flank"; + mapType = Factory.MapType.MAP_B; + } + + @Override + public Position getHudPosition(Player player) + { + return (player.is(Army.US) ? Position.TOP_RIGHT: Position.TOP_LEFT); + } + + @Override + public Player getPlayer() + { + if (!usPlayer.isDeploymentDone() || usPlayer.getCurrentTurn() == 1) + return usPlayer; + if (usPlayer.getTurnDone() > gePlayer.getTurnDone()) + return gePlayer; + return usPlayer; + } + + public Player checkVictory(Ctrl ctrl) + { + if (ctrl.opponent.unitsLeft() == 0) + return ctrl.player; + + if ((ctrl.player.getTurnDone() < 9) || (ctrl.opponent.getTurnDone() < 9)) + return null; + + int gePoints = usPlayer.casualties(); + int usPoints = gePlayer.casualties(); + usPoints += ctrl.map.objectives.count(Army.US); + + int withdrawed = usPlayer.withdrawed(); + if (withdrawed == 0) + gePoints += 1; + else + usPoints += withdrawed; + + if (usPoints > gePoints) + return usPlayer; + else + return gePlayer; + } + + @Override + public boolean getReinforcement(Ctrl ctrl, Map map) + { + if (ctrl.player.is(Army.US)) + return false; + if (ctrl.player.getCurrentTurn() != 3) + return false; + + // hex rows I + Zone geEntry = new Zone(map, 9); + geEntry.allowedMoves = (Orientation.SOUTH_WEST.s | Orientation.NORTH_WEST.s); + for (int i = 0; i < 10; i++) + geEntry.add(map.getHex(i, 0)); + addEntryZone(geEntry); + + addReinforcement(gePlayer, geEntry, UnitId.GE_TIGER, true); + + return true; + } + + @Override + public void setup(Ctrl ctrl, Map map) + { + // F6, E6 + map.addHoldObjective(5, 3, Army.NONE); + map.addObjective(6, 4, Army.NONE); + + // hex rows D-I + Zone geEntry = new Zone(map, 57); + geEntry.orientation = Orientation.NORTH; + for (int i = 3; i < 12; i++) + geEntry.add(map.getHex(i, 5)); + for (int i = 2; i < 12; i++) + geEntry.add(map.getHex(i, 4)); + for (int i = 2; i < 11; i++) + geEntry.add(map.getHex(i, 3)); + for (int i = 1; i < 11; i++) + geEntry.add(map.getHex(i, 2)); + for (int i = 1; i < 10; i++) + geEntry.add(map.getHex(i, 1)); + for (int i = 0; i < 10; i++) + geEntry.add(map.getHex(i, 0)); + + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV_HQ); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV_HQ); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_PANZER_IV); + addReinforcement(gePlayer, geEntry, UnitId.GE_AT_GUN); + addReinforcement(gePlayer, geEntry, UnitId.GE_INFANTRY); + + // hex row I + Zone usExit = new Zone(map, 10); + usExit.orientation = Orientation.NORTH_EAST; + for (int i = 0; i < 10; i++) + geEntry.add(map.getHex(i, 0)); + addExitZone(usExit); + + // hex rows A-B + Zone usEntry = new Zone(map, 19); + usEntry.orientation = Orientation.SOUTH_EAST; + for (int i = 4; i < 13; i++) { + usEntry.add(map.getHex(i, 8)); + usEntry.add(map.getHex(i, 7)); + } + usEntry.add(map.getHex(13, 8)); + addEntryZone(usEntry); + + addReinforcement(usPlayer, usEntry, usExit, UnitId.US_SHERMAN_HQ); + addReinforcement(usPlayer, usEntry, usExit, UnitId.US_SHERMAN_HQ); + addReinforcement(usPlayer, usEntry, usExit, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, usExit, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, usExit, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, usExit, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, usExit, UnitId.US_SHERMAN); + addReinforcement(usPlayer, usEntry, usExit, UnitId.US_INFANTRY); + addReinforcement(usPlayer, usEntry, usExit, UnitId.US_INFANTRY); + addReinforcement(usPlayer, usEntry, usExit, UnitId.US_PRIEST); + } +} diff --git a/old/MapA.java b/old/MapA.java new file mode 100644 index 0000000..8e772b8 --- /dev/null +++ b/old/MapA.java @@ -0,0 +1,95 @@ +package ch.asynk.rustanddust.game.battles; + +import ch.asynk.rustanddust.RustAndDust; +import ch.asynk.rustanddust.engine.Board; +import ch.asynk.rustanddust.engine.Orientation; +import ch.asynk.rustanddust.game.Map; +import ch.asynk.rustanddust.game.Hex; + +public class MapA extends Map +{ + public MapA(final RustAndDust game, String map, String hex) + { + super(game, map, hex); + } + + @Override + protected Board.Config getConfig() + { + Board.Config cfg = new Board.Config(); + cfg.cols = 10; + cfg.rows = 9; + cfg.x0 = 86; + cfg.y0 = 182; + cfg.w = 189; + cfg.dw = 94; + cfg.s = 110; + cfg.dh = 53.6f; + cfg.h = cfg.s + cfg.dh; + cfg.slope = (cfg.dh / (float) cfg.dw); + + return cfg; + } + + @Override + protected void setup() + { + getHex(5, 1).terrain = Hex.Terrain.HILLS; + getHex(7, 3).terrain = Hex.Terrain.HILLS; + getHex(7, 8).terrain = Hex.Terrain.HILLS; + getHex(8, 8).terrain = Hex.Terrain.HILLS; + + getHex(5, 0).terrain = Hex.Terrain.WOODS; + getHex(6, 0).terrain = Hex.Terrain.WOODS; + getHex(3, 3).terrain = Hex.Terrain.WOODS; + getHex(4, 3).terrain = Hex.Terrain.WOODS; + getHex(10, 7).terrain = Hex.Terrain.WOODS; + getHex(11, 7).terrain = Hex.Terrain.WOODS; + getHex(11, 8).terrain = Hex.Terrain.WOODS; + + getHex(6, 1).terrain = Hex.Terrain.TOWN; + getHex(2, 2).terrain = Hex.Terrain.TOWN; + getHex(6, 4).terrain = Hex.Terrain.TOWN; + getHex(10, 5).terrain = Hex.Terrain.TOWN; + getHex(7, 7).terrain = Hex.Terrain.TOWN; + getHex(4, 6).terrain = Hex.Terrain.TOWN; + + getHex(10, 1).terrain = Hex.Terrain.OFFMAP; + getHex(11, 3).terrain = Hex.Terrain.OFFMAP; + getHex(12, 5).terrain = Hex.Terrain.OFFMAP; + getHex(13, 7).terrain = Hex.Terrain.OFFMAP; + + int N = Orientation.NORTH.s; + int S = Orientation.SOUTH.s; + int NE = Orientation.NORTH_EAST.s; + int NW = Orientation.NORTH_WEST.s; + int SE = Orientation.SOUTH_EAST.s; + int SW = Orientation.SOUTH_WEST.s; + + getHex(6, 1).roads = (NW | SW); + for (int i = 1; i < 11; i++) { + if (i == 6) + getHex(i, 2).roads = (NE | S | SW); + else if (i == 7) + getHex(i, 2).roads = (N | SE); + else + getHex(i, 2).roads = (N | S); + } + getHex(6, 3).roads = (NE | SW); + getHex(6, 4).roads = (N | NE | SW); + getHex(7, 4).roads = (N | S); + getHex(8, 4).roads = (NW | S); + getHex(6, 5).roads = (NE | SW); + getHex(8, 5).roads = (N | SW); + getHex(9, 5).roads = (N | S | NE); + getHex(10, 5).roads = (N | S); + getHex(11, 5).roads = (N | S); + getHex(3, 6).roads = (N | S); + getHex(4, 6).roads = (N | S); + getHex(5, 6).roads = (N | S); + getHex(6, 6).roads = (NE | NW | S); + getHex(8, 6).roads = (NE | SW); + getHex(7, 7).roads = (N | SE); + getHex(8, 7).roads = (NE | S); + } +} diff --git a/old/MapB.java b/old/MapB.java new file mode 100644 index 0000000..f882f69 --- /dev/null +++ b/old/MapB.java @@ -0,0 +1,93 @@ +package ch.asynk.rustanddust.game.battles; + +import ch.asynk.rustanddust.RustAndDust; +import ch.asynk.rustanddust.engine.Board; +import ch.asynk.rustanddust.engine.Orientation; +import ch.asynk.rustanddust.game.Map; +import ch.asynk.rustanddust.game.Hex; + +public class MapB extends Map +{ + public MapB(final RustAndDust game, String map, String hex) + { + super(game, map, hex); + } + + @Override + protected Board.Config getConfig() + { + Board.Config cfg = new Board.Config(); + cfg.cols = 10; + cfg.rows = 9; + cfg.x0 = 86; + cfg.y0 = 182; + cfg.w = 189; + cfg.dw = 94; + cfg.s = 110; + cfg.dh = 53.6f; + cfg.h = cfg.s + cfg.dh; + cfg.slope = (cfg.dh / (float) cfg.dw); + + return cfg; + } + + @Override + protected void setup() + { + getHex(4, 0).terrain = Hex.Terrain.HILLS; + getHex(5, 0).terrain = Hex.Terrain.HILLS; + getHex(1, 1).terrain = Hex.Terrain.HILLS; + getHex(9, 7).terrain = Hex.Terrain.HILLS; + getHex(10, 7).terrain = Hex.Terrain.HILLS; + + getHex(3, 0).terrain = Hex.Terrain.WOODS; + getHex(6, 0).terrain = Hex.Terrain.WOODS; + getHex(8, 1).terrain = Hex.Terrain.WOODS; + getHex(9, 2).terrain = Hex.Terrain.WOODS; + getHex(4, 5).terrain = Hex.Terrain.WOODS; + getHex(5, 6).terrain = Hex.Terrain.WOODS; + getHex(6, 6).terrain = Hex.Terrain.WOODS; + getHex(11, 8).terrain = Hex.Terrain.WOODS; + + getHex(1, 2).terrain = Hex.Terrain.TOWN; + getHex(5, 3).terrain = Hex.Terrain.TOWN; + getHex(6, 4).terrain = Hex.Terrain.TOWN; + getHex(7, 8).terrain = Hex.Terrain.TOWN; + + getHex(10, 1).terrain = Hex.Terrain.OFFMAP; + getHex(11, 3).terrain = Hex.Terrain.OFFMAP; + getHex(12, 5).terrain = Hex.Terrain.OFFMAP; + getHex(13, 7).terrain = Hex.Terrain.OFFMAP; + + int N = Orientation.NORTH.s; + int S = Orientation.SOUTH.s; + int NE = Orientation.NORTH_EAST.s; + int NW = Orientation.NORTH_WEST.s; + int SE = Orientation.SOUTH_EAST.s; + int SW = Orientation.SOUTH_WEST.s; + + getHex(1, 2).roads = (S | NW); + getHex(2, 3).roads = (SE | N); + getHex(3, 3).roads = (S | N); + getHex(4, 3).roads = (S | N); + getHex(5, 3).roads = (S | NW); + getHex(6, 4).roads = (SE | N); + getHex(7, 4).roads = (S | N); + getHex(8, 4).roads = (S | SW | N); + getHex(9, 4).roads = (S | N); + getHex(10, 4).roads = (S | N); + getHex(11, 4).roads = (S | N); + getHex(4, 8).roads = (S | N); + getHex(5, 8).roads = (S | N); + getHex(6, 8).roads = (S | N); + getHex(7, 8).roads = (S | N); + getHex(8, 8).roads = (S | NE); + getHex(8, 7).roads = (SW | NE); + getHex(8, 6).roads = (SW | NE | N); + getHex(8, 5).roads = (SW | NE); + getHex(9, 6).roads = (S | N); + getHex(10, 6).roads = (S | N); + getHex(11, 6).roads = (S | N); + getHex(12, 6).roads = (S | N); + } +} |