diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank/engine')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Player.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Player.java b/core/src/ch/asynk/tankontank/engine/Player.java new file mode 100644 index 0000000..c1c9365 --- /dev/null +++ b/core/src/ch/asynk/tankontank/engine/Player.java @@ -0,0 +1,68 @@ +package ch.asynk.tankontank.engine; + +import java.util.ArrayList; +import java.util.Random; +import java.util.Iterator; + +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 abstract void turnEnd(); + public abstract void turnStart(); + + public Player(Faction faction, int n) + { + this.faction = faction; + this.units = new ArrayList<Pawn>(n); + this.casualties = new ArrayList<Pawn>(n); + this.reinforcement = new ArrayList<Pawn>(n); + } + + public String getName() + { + return faction.toString(); + } + + public boolean isEnemy(Pawn pawn) + { + return pawn.isEnemy(faction); + } + + public void addUnit(Pawn pawn) + { + units.add(pawn); + } + + public void addReinforcement(Pawn pawn) + { + reinforcement.add(pawn); + } + + public void casualty(Pawn pawn) + { + units.remove(pawn); + casualties.add(pawn); + System.err.println(" casualty : " + pawn); + } + + public Iterator<Pawn> unitIterator() + { + return units.iterator(); + } + + public Iterator<Pawn> casualtiesIterator() + { + return casualties.iterator(); + } + + public Iterator<Pawn> reinforcementIterator() + { + return reinforcement.iterator(); + } +} |