From 4dcfa7ba19ac5b9f0522f92ee10f43ade20b57de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 3 Feb 2016 00:35:56 +0100 Subject: BattleCommon: replace Player a, b with Player[2] players --- core/src/ch/asynk/rustanddust/game/battles/Battle00.java | 4 ++-- .../ch/asynk/rustanddust/game/battles/BattleCommon.java | 15 +++++++++------ .../src/ch/asynk/rustanddust/game/battles/BattleTest.java | 4 ++-- 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 entryZones = new IterableArray(10); protected IterableArray exitZones = new IterableArray(10); protected HashMap unitEntry = new HashMap(); @@ -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 -- cgit v1.1-2-g2b99