summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/src/ch/asynk/tankontank/game/Player.java13
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateAttack.java5
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);