diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-24 20:00:42 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-24 20:00:42 +0100 |
commit | 6ed8291b0b11c9f1b29e1e60390bd29f6bb3be2c (patch) | |
tree | b4d68a29b52c9d90ea050bbde73acf86af81b4df /core/src | |
parent | 0d21b8a92b1df2b8765cc1802e0b8c7f48cd4745 (diff) | |
download | RustAndDust-6ed8291b0b11c9f1b29e1e60390bd29f6bb3be2c.zip RustAndDust-6ed8291b0b11c9f1b29e1e60390bd29f6bb3be2c.tar.gz |
Battle: merge start() into setup()
Diffstat (limited to 'core/src')
5 files changed, 47 insertions, 36 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Battle.java b/core/src/ch/asynk/rustanddust/game/Battle.java index 8be82c1..5b1451e 100644 --- a/core/src/ch/asynk/rustanddust/game/Battle.java +++ b/core/src/ch/asynk/rustanddust/game/Battle.java @@ -21,8 +21,6 @@ public interface Battle public Map setup(); - public void start(); - public boolean actionDone(); public boolean turnDone(); diff --git a/core/src/ch/asynk/rustanddust/game/Ctrl.java b/core/src/ch/asynk/rustanddust/game/Ctrl.java index 302ca87..257df35 100644 --- a/core/src/ch/asynk/rustanddust/game/Ctrl.java +++ b/core/src/ch/asynk/rustanddust/game/Ctrl.java @@ -85,7 +85,6 @@ public abstract class Ctrl implements Disposable this.hud = new Hud(game); StateCommon.set(game); - battle.start(); hud.update(); setState(battle.getState()); diff --git a/core/src/ch/asynk/rustanddust/game/battles/Battle00.java b/core/src/ch/asynk/rustanddust/game/battles/Battle00.java index 335ee57..c8564fe 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/Battle00.java +++ b/core/src/ch/asynk/rustanddust/game/battles/Battle00.java @@ -32,16 +32,6 @@ public class Battle00 extends BattleCommon } @Override - public void start() - { - map.actionDone(); - map.turnDone(); - usPlayer.turnEnd(); - gePlayer.turnEnd(); - currentPlayer = usPlayer; - } - - @Override public Player getWinner() { return getWinner(8); @@ -54,14 +44,21 @@ public class Battle00 extends BattleCommon } @Override - public Map setup() + protected Player getFirstPlayer() { - super.setup(); + return usPlayer; + } + @Override + protected void setupMap() + { map.addHoldObjective(5, 2, Army.NONE); map.addObjective(11, 7, Army.US); + } - currentPlayer = usPlayer; + @Override + protected void setupUS() + { setUnit(map, usPlayer, UnitId.US_AT_GUN, 11, 7, Orientation.SOUTH, null); Zone usEntry = new Zone(map, 10); @@ -85,7 +82,11 @@ public class Battle00 extends BattleCommon addReinforcement(usPlayer, usEntry, UnitId.US_WOLVERINE); addReinforcement(usPlayer, usEntry, UnitId.US_PERSHING); addReinforcement(usPlayer, usEntry, UnitId.US_PRIEST); + } + @Override + protected void setupGE() + { Zone geEntry = new Zone(map, 8); geEntry.orientation = Orientation.NORTH; geEntry.add(4, 8); @@ -104,7 +105,5 @@ public class Battle00 extends BattleCommon addReinforcement(gePlayer, geEntry, UnitId.GE_TIGER); addReinforcement(gePlayer, geEntry, UnitId.GE_TIGER); addReinforcement(gePlayer, geEntry, UnitId.GE_WESPE); - - return this.map; } } diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java index 2f57d95..ff72408 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java @@ -34,7 +34,11 @@ public abstract class BattleCommon implements Battle protected HashMap<Unit, Zone> unitEntry = new HashMap<Unit, Zone>(); protected HashMap<Unit, Zone> unitExit = new HashMap<Unit, Zone>(); - public abstract Player getWinner(); + protected abstract Player getWinner(); + protected abstract void setupMap(); + protected abstract void setupUS(); + protected abstract void setupGE(); + protected abstract Player getFirstPlayer(); private int d6() { @@ -91,8 +95,21 @@ public abstract class BattleCommon implements Battle public Map setup() { this.map = factory.getMap(mapType); - this.usPlayer = factory.getPlayer(Army.US); - this.gePlayer = factory.getPlayer(Army.GE); + setupMap(); + + this.currentPlayer = this.usPlayer = factory.getPlayer(Army.US); + setupUS(); + map.actionDone(); + currentPlayer.turnEnd(); + map.turnDone(); + + this.currentPlayer = this.gePlayer = factory.getPlayer(Army.GE); + setupGE(); + map.actionDone(); + currentPlayer.turnEnd(); + map.turnDone(); + + this.currentPlayer = getFirstPlayer(); return this.map; } diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java index 11af25e..d5cb9a9 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java @@ -29,19 +29,15 @@ public class BattleTest extends BattleCommon } @Override - public void start() + public Player getWinner() { - map.actionDone(); - map.turnDone(); - usPlayer.turnEnd(); - gePlayer.turnEnd(); - currentPlayer = gePlayer; + return getWinner(4); } @Override - public Player getWinner() + protected Player getFirstPlayer() { - return getWinner(4); + return gePlayer; } @Override @@ -62,16 +58,17 @@ public class BattleTest extends BattleCommon } @Override - public Map setup() + protected void setupMap() { - 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; + @Override + protected void setupGE() + { 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); @@ -86,8 +83,11 @@ public class BattleTest extends BattleCommon geEntry.add(3, 4); addEntryZone(geEntry); addReinforcement(gePlayer, geEntry, UnitId.GE_AT_GUN); + } - currentPlayer = usPlayer; + @Override + protected void setupUS() + { usExit = new Zone(map, 9); usExit.orientation = Orientation.NORTH; usExit.add(11, 4); @@ -103,7 +103,5 @@ public class BattleTest extends BattleCommon 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; } } |