diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-17 16:33:26 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-17 16:33:26 +0200 |
commit | 70f26f0bd227ec9871447d9582b4f7cb78f01a4b (patch) | |
tree | 4f8ea37ae9e070c4e6c5b72441fce12f96704c9b /core/src/ch/asynk/tankontank/engine | |
parent | 4af430e68750e56cc62ddba117f48ef9aff65619 (diff) | |
download | RustAndDust-70f26f0bd227ec9871447d9582b4f7cb78f01a4b.zip RustAndDust-70f26f0bd227ec9871447d9582b4f7cb78f01a4b.tar.gz |
Player: -> engine/Player and game/Player
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(); + } +} |