From 0c84007ab76062e7289ac9122ef3a02de9c9490e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 17 Oct 2014 10:43:05 +0200 Subject: Player: add turn and apSpent attributes --- core/src/ch/asynk/tankontank/game/Player.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/src/ch/asynk/tankontank/game/Player.java b/core/src/ch/asynk/tankontank/game/Player.java index b164d2d..2dbc1b6 100644 --- a/core/src/ch/asynk/tankontank/game/Player.java +++ b/core/src/ch/asynk/tankontank/game/Player.java @@ -26,6 +26,8 @@ public class Player implements Drawable, Disposable private Army army; private Image flag; private Msg status; + private int turn; + private int apSpent; private int actionPoints; private ArrayList units; private ArrayList casualties; @@ -34,6 +36,7 @@ public class Player implements Drawable, Disposable public Player(final TankOnTank game, Army army, BitmapFont font, TextureAtlas atlas, String name, int size) { this.army = army; + this.turn = 0; this.actionPoints = 0; this.flag = new Image(atlas.findRegion(name)); this.units = new ArrayList(size); @@ -73,29 +76,27 @@ public class Player implements Drawable, Disposable public boolean apExhausted() { - return (actionPoints <= 0); + return (apSpent == actionPoints); } public void burnDownOneAp() { - actionPoints -= 1; + apSpent += 1; updateInfo(); - System.err.println("1 AP burned " + toString()); - if (actionPoints < 0) System.err.println("ERROR: AP < 0, damn that's very wrong, please report"); + if (apSpent > actionPoints) System.err.println("ERROR: spent too much AP, please report"); } public void turnEnd() { - System.err.println("TurnEnd " + toString()); } public void turnStart() { + turn += 1; for (Pawn pawn : units) pawn.reset(); computeActionPoints(); updateInfo(); - System.err.println("TurnStart " + toString()); } public int d6() @@ -111,11 +112,12 @@ public class Player implements Drawable, Disposable if (d6() > 3) this.actionPoints += 1; } + apSpent = 0; } private void updateInfo() { - status.write("AP: " + actionPoints, flag.getX(), (flag.getY() - 40), 0, 10); + status.write("Turn: " + turn + " AP: " + (apSpent + 1), flag.getX(), (flag.getY() - 40), 0, 10); } public boolean isEnemy(Pawn pawn) -- cgit v1.1-2-g2b99