diff options
Diffstat (limited to 'core/src/ch/asynk/rustanddust/game')
3 files changed, 13 insertions, 10 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/battles/Battle00.java b/core/src/ch/asynk/rustanddust/game/battles/Battle00.java index 4381303..4dcf702 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/Battle00.java +++ b/core/src/ch/asynk/rustanddust/game/battles/Battle00.java @@ -27,8 +27,8 @@ public class Battle00 extends BattleCommon @Override protected void setPlayers(int idA, int idB) { - a = factory.getPlayer(idA, Army.US); - b = factory.getPlayer(idB, Army.GE); + players[0] = factory.getPlayer(idA, Army.US); + players[1] = factory.getPlayer(idB, Army.GE); } @Override diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java index f34e594..4551d78 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java @@ -29,8 +29,7 @@ public abstract class BattleCommon implements Battle protected String description; protected Map map; protected Player currentPlayer; - protected Player a; - protected Player b; + protected Player[] players; protected IterableArray<Zone> entryZones = new IterableArray<Zone>(10); protected IterableArray<Zone> exitZones = new IterableArray<Zone>(10); protected HashMap<Unit, Zone> unitEntry = new HashMap<Unit, Zone>(); @@ -60,6 +59,7 @@ public abstract class BattleCommon implements Battle public BattleCommon(Factory factory) { this.factory = factory; + this.players = new Player[2]; } @Override @@ -112,19 +112,19 @@ public abstract class BattleCommon implements Battle setupMap(); - this.currentPlayer = this.a; + this.currentPlayer = players[0]; setupPlayer(); map.actionDone(); map.turnDone(); currentPlayer.turnEnd(); - this.currentPlayer = this.b; + this.currentPlayer = players[1]; setupPlayer(); map.actionDone(); map.turnDone(); currentPlayer.turnEnd(); - this.currentPlayer = this.a; + this.currentPlayer = players[0]; } @Override @@ -163,6 +163,9 @@ public abstract class BattleCommon implements Battle if (!turnDoneForBoth()) return null; + Player a = players[0]; + Player b = players[1]; + if (a.unitsLeft() == 0) return b; if (b.unitsLeft() == 0) @@ -191,7 +194,7 @@ public abstract class BattleCommon implements Battle @Override public Player getOpponent() { - return ((currentPlayer == a) ? b : a); + return ((currentPlayer == players[0]) ? players[1] : players[0]); } @Override diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java index 8f65575..8466841 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java @@ -24,8 +24,8 @@ public class BattleTest extends BattleCommon @Override protected void setPlayers(int idA, int idB) { - a = factory.getPlayer(idA, Army.GE); - b = factory.getPlayer(idB, Army.US); + players[0] = factory.getPlayer(idA, Army.GE); + players[1] = factory.getPlayer(idB, Army.US); } @Override |