diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-12-08 22:24:33 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-12-08 22:24:33 +0100 |
commit | 91fd50e89569c9b104f8aa3a85dc1a02f3748eb9 (patch) | |
tree | 4f9a4510c41534be41373b391044c1eb4d794f2b | |
parent | dfc3f46b764d710b7fe1b1b6c37f7ed08989cf97 (diff) | |
download | RustAndDust-91fd50e89569c9b104f8aa3a85dc1a02f3748eb9.zip RustAndDust-91fd50e89569c9b104f8aa3a85dc1a02f3748eb9.tar.gz |
Battle: owns map, set it and bath player in setup(Ctrl)
4 files changed, 19 insertions, 24 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Battle.java b/core/src/ch/asynk/rustanddust/game/Battle.java index 5e4a76d..abf91db 100644 --- a/core/src/ch/asynk/rustanddust/game/Battle.java +++ b/core/src/ch/asynk/rustanddust/game/Battle.java @@ -8,8 +8,6 @@ import ch.asynk.rustanddust.ui.Position; public interface Battle { - public void init(); - public String getName(); public String getDescription(); @@ -22,11 +20,9 @@ public interface Battle public void changePlayer(); - public Map getMap(); - public Player checkVictory(Ctrl ctrl); - public boolean getReinforcement(Ctrl ctrl, Map map); + public boolean getReinforcement(Ctrl ctrl); public Zone getEntryZone(Unit unit); @@ -38,5 +34,5 @@ public interface Battle public boolean deploymentDone(); - public void setup(Ctrl ctrl, Map map); + public Map setup(Ctrl ctrl); } diff --git a/core/src/ch/asynk/rustanddust/game/Ctrl.java b/core/src/ch/asynk/rustanddust/game/Ctrl.java index 5a11f5a..8472ba6 100644 --- a/core/src/ch/asynk/rustanddust/game/Ctrl.java +++ b/core/src/ch/asynk/rustanddust/game/Ctrl.java @@ -57,11 +57,7 @@ public class Ctrl implements Disposable this.cfg = game.config; game.ctrl = this; - battle.init(); - - this.map = battle.getMap(); - battle.setup(this, map); - this.map.init(); + this.map = battle.setup(this); this.selectState = new StateSelect(); this.pathState = new StateMove(); @@ -118,7 +114,7 @@ public class Ctrl implements Disposable { battle.getPlayer().turnStart(); // hud.notify(battle.getPlayer().getName() + "'s turn", 2, Position.MIDDLE_CENTER, true); - if (battle.getReinforcement(this, map)) + if (battle.getReinforcement(this)) hud.notify("You have reinforcement", 2, Position.MIDDLE_CENTER, true); hud.update(); setState(battle.getState()); diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java index 4585fdd..9292095 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java @@ -24,6 +24,7 @@ public abstract class BattleCommon implements Battle protected String name; protected String description; protected Factory factory; + protected Map map; protected Player currentPlayer; protected Player usPlayer; protected Player gePlayer; @@ -38,13 +39,6 @@ public abstract class BattleCommon implements Battle } @Override - public void init() - { - this.usPlayer = factory.getPlayer(Army.US); - this.gePlayer = factory.getPlayer(Army.GE); - } - - @Override public String toString() { return getName(); @@ -69,9 +63,13 @@ public abstract class BattleCommon implements Battle } @Override - public Map getMap() + public Map setup(Ctrl ctrl) { - return factory.getMap(mapType); + this.map = factory.getMap(mapType); + this.usPlayer = factory.getPlayer(Army.US); + this.gePlayer = factory.getPlayer(Army.GE); + + return this.map; } @Override @@ -107,7 +105,7 @@ public abstract class BattleCommon implements Battle } @Override - public boolean getReinforcement(Ctrl ctrl, Map map) + public boolean getReinforcement(Ctrl ctrl) { return false; } diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java index df3ff2a..7faa0cc 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java @@ -38,7 +38,7 @@ public class BattleTest extends BattleCommon } @Override - public boolean getReinforcement(Ctrl ctrl, Map map) + public boolean getReinforcement(Ctrl ctrl) { if (currentPlayer.is(Army.GE)) return false; @@ -70,8 +70,10 @@ public class BattleTest extends BattleCommon } @Override - public void setup(Ctrl ctrl, Map map) + public Map setup(Ctrl ctrl) { + super.setup(ctrl); + map.addObjective(5, 2, Army.NONE); map.addHoldObjective(5, 3, Army.NONE); map.addObjective(3, 4, Army.NONE); @@ -83,6 +85,7 @@ public class BattleTest extends BattleCommon 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); geEntry.orientation = Orientation.NORTH; geEntry.add(map.getHex(1, 2)); @@ -112,5 +115,7 @@ public class BattleTest extends BattleCommon map.init(); map.turnDone(); currentPlayer = gePlayer; + + return this.map; } } |