diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-10 15:03:31 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-10 15:03:31 +0100 |
commit | 7e03cb2842d9140682374ec12e108333f895ce03 (patch) | |
tree | b91a48a234b6b924b3a33d32fa3a5d81c4bbcfbb /core/src | |
parent | 5ccc85eae3da7e5bd171bd17e6632114ddfe50a7 (diff) | |
download | RustAndDust-7e03cb2842d9140682374ec12e108333f895ce03.zip RustAndDust-7e03cb2842d9140682374ec12e108333f895ce03.tar.gz |
Player,StateAttack: add statistics counters
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Player.java | 13 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateAttack.java | 5 |
2 files changed, 17 insertions, 1 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Player.java b/core/src/ch/asynk/tankontank/game/Player.java index 2a6e5a9..f032124 100644 --- a/core/src/ch/asynk/tankontank/game/Player.java +++ b/core/src/ch/asynk/tankontank/game/Player.java @@ -14,12 +14,19 @@ public class Player extends ch.asynk.tankontank.engine.Player private int turn; private int apSpent; private int actionPoints; + // stats + public int actionCount; + public int lostAttackCount; + public int wonAttackCount; public Player(final TankOnTank game, Army army, int n) { super(army, n); this.turn = 0; this.actionPoints = 0; + this.actionCount = 0; + this.lostAttackCount = 0; + this.wonAttackCount = 0; } public String toString() @@ -28,6 +35,11 @@ public class Player extends ch.asynk.tankontank.engine.Player " units:" + units.size() + " casualties:" + casualties.size(); } + public String getStats() + { + return String.format("%s\n%4d\n%4d\n%4d\n%4d\n%4d", getName(), actionCount, unitsLeft(), casualties.size(), wonAttackCount, lostAttackCount); + } + public int getAp() { return (apSpent + 1); @@ -46,6 +58,7 @@ public class Player extends ch.asynk.tankontank.engine.Player public void burnDownOneAp() { apSpent += 1; + actionCount += 1; if (apSpent > actionPoints) TankOnTank.debug("ERROR: spent too much AP, please report"); } diff --git a/core/src/ch/asynk/tankontank/game/states/StateAttack.java b/core/src/ch/asynk/tankontank/game/states/StateAttack.java index e2ed73e..7bdb925 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateAttack.java +++ b/core/src/ch/asynk/tankontank/game/states/StateAttack.java @@ -86,14 +86,17 @@ public class StateAttack extends StateCommon int d1 = ctrl.player.d6(); int d2 = ctrl.player.d6(); if (map.attackPawn(selectedUnit, activeUnit, d1, d2)) { + ctrl.player.wonAttackCount += 1; ctrl.hud.notify(selectedUnit.attack.calculus + " : " + activeUnit + " is destroyed"); ctrl.opponent.casualty(activeUnit); if (map.breakPawns.size() > 0) { ctrl.hud.pushNotify("Break move possible"); setNextState(StateType.BREAK); } - } else + } else { + ctrl.player.lostAttackCount += 1; ctrl.hud.notify(selectedUnit.attack.calculus + " : failure"); + } activeUnit.showTarget(); ctrl.setState(StateType.ANIMATION); |