diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-03-07 19:59:16 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-03-07 19:59:16 +0100 |
commit | 6fbcdfdcfb3824acc4ce20d0922492fff8cd546d (patch) | |
tree | 215857f8da7dbb2d80efd2d257eb8b21bed5b812 /core/src/ch/asynk/rustanddust/game/battles | |
parent | 9ae4744a90f032a6bdc92b9c0389f0bc696e9e7f (diff) | |
download | RustAndDust-6fbcdfdcfb3824acc4ce20d0922492fff8cd546d.zip RustAndDust-6fbcdfdcfb3824acc4ce20d0922492fff8cd546d.tar.gz |
Battle: clean up the API
Diffstat (limited to 'core/src/ch/asynk/rustanddust/game/battles')
3 files changed, 41 insertions, 39 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/battles/Battle00.java b/core/src/ch/asynk/rustanddust/game/battles/Battle00.java index c3ea89f..949ca04 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/Battle00.java +++ b/core/src/ch/asynk/rustanddust/game/battles/Battle00.java @@ -25,13 +25,6 @@ public class Battle00 extends BattleCommon } @Override - protected void setPlayers() - { - players[0] = factory.getPlayer(Army.US); - players[1] = factory.getPlayer(Army.GE); - } - - @Override public Position getHudPosition() { return (currentPlayer.is(Army.US) ? Position.TOP_RIGHT: Position.TOP_LEFT); @@ -49,15 +42,20 @@ public class Battle00 extends BattleCommon return false; } + // SETUP + @Override - protected void setupMap() + protected void setup() { + players[0] = factory.getPlayer(Army.US); + players[1] = factory.getPlayer(Army.GE); + map.addHoldObjective(5, 2, Army.NONE); map.addObjective(11, 7, Army.US); } @Override - protected void setupPlayer() + protected void deployPlayer() { if (currentPlayer.army == Army.US) setupUS(currentPlayer); diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java index 0e6b00b..4a705ed 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java @@ -30,9 +30,8 @@ public abstract class BattleCommon implements Battle protected Player[] players; protected abstract Player getWinner(); - protected abstract void setupMap(); - protected abstract void setupPlayer(); - protected abstract void setPlayers(); + protected abstract void setup(); + protected abstract void deployPlayer(); private int d6() { @@ -56,12 +55,6 @@ public abstract class BattleCommon implements Battle this.players = new Player[2]; } - @Override - public String unload(boolean full) - { - return map.unload(full, getPlayer(), getOpponent()); - } - @Override public int getId() { return _id; } @Override public String toString() { return getName(); } @Override public String getName() { return name; } @@ -70,21 +63,31 @@ public abstract class BattleCommon implements Battle @Override public Factory.MapType getMapType() { return mapType; } @Override - public void init(Ctrl ctrl, int idA, int idB) + public void init() { - ctrl.map = this.map = factory.getMap(getMapType()); - setPlayers(); - players[0].id = idA; - players[1].id = idB; + this.map = factory.getMap(getMapType()); + setup(); + this.currentPlayer = players[0]; + } - setupMap(); + @Override + public void desinit() + { + this.map = null; + this.players[0] = null; + this.players[1] = null; + this.currentPlayer = null; + } + @Override + public void initialDeployment() + { this.currentPlayer = players[0]; - setupPlayer(); + deployPlayer(); currentPlayer.turnEnd(); this.currentPlayer = players[1]; - setupPlayer(); + deployPlayer(); currentPlayer.turnEnd(); this.currentPlayer = players[0]; @@ -92,12 +95,15 @@ public abstract class BattleCommon implements Battle } @Override - public void init(Ctrl ctrl, String payload) + public void load(String payload) { - ctrl.map = this.map = factory.getMap(getMapType()); - setupMap(); map.load(payload, players); - currentPlayer = players[0]; + } + + @Override + public String unload(boolean full) + { + return map.unload(full, getPlayer(), getOpponent()); } @Override diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java index 8255722..d66dae6 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java @@ -22,13 +22,6 @@ public class BattleTest extends BattleCommon } @Override - protected void setPlayers() - { - players[0] = factory.getPlayer(Army.GE); - players[1] = factory.getPlayer(Army.US); - } - - @Override public Position getHudPosition() { return (currentPlayer.is(Army.US) ? Position.TOP_RIGHT: Position.TOP_LEFT); @@ -57,9 +50,14 @@ public class BattleTest extends BattleCommon return true; } + // SETUP + @Override - protected void setupMap() + protected void setup() { + players[0] = factory.getPlayer(Army.GE); + players[1] = factory.getPlayer(Army.US); + map.addObjective(5, 2, Army.NONE); map.addHoldObjective(5, 3, Army.NONE); map.addObjective(3, 4, Army.NONE); @@ -67,7 +65,7 @@ public class BattleTest extends BattleCommon } @Override - protected void setupPlayer() + protected void deployPlayer() { if (currentPlayer.army == Army.US) setupUS(currentPlayer); |