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 units; protected ArrayList casualties; protected ArrayList reinforcement; public abstract void turnEnd(); public abstract void turnStart(); public Player(Faction faction, int n) { this.faction = faction; this.units = new ArrayList(n); this.casualties = new ArrayList(n); this.reinforcement = new ArrayList(n); } public Faction getFaction() { return faction; } public int unitsLeft() { return (units.size() + reinforcement.size()); } public int reinforcementCount() { return reinforcement.size(); } public String getName() { return faction.toString(); } public boolean isEnemy(Pawn pawn) { return pawn.isEnemy(faction); } public boolean isEnemy(Faction other) { return faction.isEnemy(other); } 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 unitIterator() { return units.iterator(); } public Iterator casualtiesIterator() { return casualties.iterator(); } public Iterator reinforcementIterator() { return reinforcement.iterator(); } }