diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-03-07 15:40:04 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-03-07 15:40:04 +0100 |
commit | d88c5cc130025eb2a0214436a86c15dad2787589 (patch) | |
tree | 604355e533d9c5b7b316ddd4451c36498862436c /core/src/ch/asynk/rustanddust | |
parent | 6a87c1f59fd2fa379aeda871cf4535038756cb5e (diff) | |
download | RustAndDust-d88c5cc130025eb2a0214436a86c15dad2787589.zip RustAndDust-d88c5cc130025eb2a0214436a86c15dad2787589.tar.gz |
Player: remove id from constructor
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
7 files changed, 21 insertions, 23 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Factory.java b/core/src/ch/asynk/rustanddust/game/Factory.java index 398ac70..5817ab9 100644 --- a/core/src/ch/asynk/rustanddust/game/Factory.java +++ b/core/src/ch/asynk/rustanddust/game/Factory.java @@ -105,12 +105,12 @@ public class Factory implements Board.TileBuilder, Disposable return m; } - public Player getPlayer(int id, Army army) + public Player getPlayer(Army army) { if (army == Army.US) - return new Player(id, Army.US); + return new Player(Army.US); else - return new Player(id, Army.GE); + return new Player(Army.GE); } public Unit getUnit(UnitCode code, boolean hq, boolean ace) diff --git a/core/src/ch/asynk/rustanddust/game/Player.java b/core/src/ch/asynk/rustanddust/game/Player.java index 1263ff4..b4b5772 100644 --- a/core/src/ch/asynk/rustanddust/game/Player.java +++ b/core/src/ch/asynk/rustanddust/game/Player.java @@ -7,7 +7,7 @@ public class Player private static final float MOVE_TIME = 0.4f; private static final int N = 10; - private int id; + public int id; private int turn; private int apSpent; private int ap; @@ -23,9 +23,9 @@ public class Player public int engagementWon; public int engagementLost; - public Player(int id, Army army) + public Player(Army army) { - this.id = id; + this.id = -1; this.army = army; this.units = new UnitList(N); this.casualties = new UnitList(N); @@ -47,11 +47,6 @@ public class Player this.apSpent = apSpent; } - public int getId() - { - return id; - } - public String getName() { return army.toString(); diff --git a/core/src/ch/asynk/rustanddust/game/battles/Battle00.java b/core/src/ch/asynk/rustanddust/game/battles/Battle00.java index 1ede61e..c3ea89f 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/Battle00.java +++ b/core/src/ch/asynk/rustanddust/game/battles/Battle00.java @@ -25,10 +25,10 @@ public class Battle00 extends BattleCommon } @Override - protected void setPlayers(int idA, int idB) + protected void setPlayers() { - players[0] = factory.getPlayer(idA, Army.US); - players[1] = factory.getPlayer(idB, Army.GE); + players[0] = factory.getPlayer(Army.US); + players[1] = factory.getPlayer(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 f80d01f..0e6b00b 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java @@ -32,7 +32,7 @@ public abstract class BattleCommon implements Battle protected abstract Player getWinner(); protected abstract void setupMap(); protected abstract void setupPlayer(); - protected abstract void setPlayers(int idA, int idB); + protected abstract void setPlayers(); private int d6() { @@ -73,7 +73,9 @@ public abstract class BattleCommon implements Battle public void init(Ctrl ctrl, int idA, int idB) { ctrl.map = this.map = factory.getMap(getMapType()); - setPlayers(idA, idB); + setPlayers(); + players[0].id = idA; + players[1].id = idB; setupMap(); diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java index d2279cb..8255722 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java @@ -22,10 +22,10 @@ public class BattleTest extends BattleCommon } @Override - protected void setPlayers(int idA, int idB) + protected void setPlayers() { - players[0] = factory.getPlayer(idA, Army.GE); - players[1] = factory.getPlayer(idB, Army.US); + players[0] = factory.getPlayer(Army.GE); + players[1] = factory.getPlayer(Army.US); } @Override diff --git a/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java b/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java index 212e5ad..58c1a4b 100644 --- a/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java +++ b/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java @@ -42,11 +42,11 @@ public class Solo extends Ctrl private void storeState() { - game.db.storeState(gameId, battle.getPlayer().getId(), battle.getOpponent().getId(), battle.unload(true)); + game.db.storeState(gameId, battle.getPlayer().id, battle.getOpponent().id, battle.unload(true)); } private void storeOrders() { - game.db.storeTurn(gameId, battle.getPlayer().getId(), battle.unload(false)); + game.db.storeTurn(gameId, battle.getPlayer().id, battle.unload(false)); } } diff --git a/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java b/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java index cc5f3c9..ec02762 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java @@ -65,7 +65,7 @@ public abstract class Map5Marshal extends Map4Orders private void unload(Json json, Player player) { json.writeObjectStart(); - json.writeValue("id", player.getId()); + json.writeValue("id", player.id); json.writeValue("a", player.army); json.writeArrayStart("v"); json.writeValue(player.getTurn()); @@ -279,7 +279,8 @@ public abstract class Map5Marshal extends Map4Orders private Player loadPlayer(JsonValue v) { - Player p = new Player(v.getInt("id"), Army.valueOf(v.getString("a"))); + Player p = new Player(Army.valueOf(v.getString("a"))); + p.id = v.getInt("id"); JsonValue a = v.get("v"); p.setTurn(a.getInt(0), a.getInt(1), a.getInt(2)); p.actionCount = a.getInt(3); |