diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-17 14:52:51 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-17 14:52:51 +0100 |
commit | 8d6f8738203d45d4da116e390b6e6685f4636bb3 (patch) | |
tree | cc78b335fcbf9f805f419d9f7aa33284b3c3b815 /core/src/ch/asynk/tankontank/engine/Player.java | |
parent | b4c82404bcb7b2e1f58339088ccf48023c1da6f9 (diff) | |
download | RustAndDust-8d6f8738203d45d4da116e390b6e6685f4636bb3.zip RustAndDust-8d6f8738203d45d4da116e390b6e6685f4636bb3.tar.gz |
Player: clean up API
Diffstat (limited to 'core/src/ch/asynk/tankontank/engine/Player.java')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Player.java | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Player.java b/core/src/ch/asynk/tankontank/engine/Player.java index cb9543d..8bda179 100644 --- a/core/src/ch/asynk/tankontank/engine/Player.java +++ b/core/src/ch/asynk/tankontank/engine/Player.java @@ -9,10 +9,10 @@ import ch.asynk.tankontank.engine.Pawn; public abstract class Player { - protected Faction faction; - protected ArrayList<Pawn> units; - protected ArrayList<Pawn> casualties; - protected ArrayList<Pawn> reinforcement; + public Faction faction; + public ArrayList<Pawn> units; + public ArrayList<Pawn> casualties; + public ArrayList<Pawn> reinforcement; public abstract void turnEnd(); public abstract void turnStart(); @@ -25,44 +25,39 @@ public abstract class Player this.reinforcement = new ArrayList<Pawn>(n); } - public Faction getFaction() - { - return faction; - } - - public List<Pawn> getReinforcement() + public String getName() { - return reinforcement; + return faction.toString(); } - public int unitsLeft() + public boolean is(Faction faction) { - return (units.size() + reinforcement.size()); + return (this.faction == faction); } - public int casualties() + public boolean isEnemy(Pawn pawn) { - return casualties.size(); + return pawn.isEnemy(faction); } - public String getName() + public boolean isEnemy(Faction other) { - return faction.toString(); + return faction.isEnemy(other); } - public boolean is(Faction faction) + public int unitsLeft() { - return (this.faction == faction); + return (units.size() + reinforcement.size()); } - public boolean isEnemy(Pawn pawn) + public int reinforcement() { - return pawn.isEnemy(faction); + return reinforcement.size(); } - public boolean isEnemy(Faction other) + public int casualties() { - return faction.isEnemy(other); + return casualties.size(); } public void addUnit(Pawn pawn) @@ -92,9 +87,4 @@ public abstract class Player units.remove(pawn); casualties.add(pawn); } - - public Iterator<Pawn> unitIterator() - { - return units.iterator(); - } } |