diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 1 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Unit.java | 14 |
2 files changed, 14 insertions, 1 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 23cbfa4..79a382d 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -64,6 +64,7 @@ public abstract class Pawn implements Moveable, Disposable public abstract boolean canAttack(Pawn other); public abstract boolean canAssistAttackWithoutLos(); + public abstract void enter(int cost); public abstract void move(int cost); public abstract void rotate(Orientation o); public abstract void attack(Pawn target); diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java index 64af758..2bea006 100644 --- a/core/src/ch/asynk/tankontank/game/Unit.java +++ b/core/src/ch/asynk/tankontank/game/Unit.java @@ -52,6 +52,7 @@ public class Unit extends HeadedPawn public int def; public int cdef; public int mp; + public int mpLeft; public UnitType type; public UnitId id; private boolean hasMoved; @@ -69,6 +70,7 @@ public class Unit extends HeadedPawn this.rng = range; this.def = defense; this.mp = movementPoints; + mpLeft = mp; this.id = id; this.type = type; this.hasMoved = false; @@ -84,6 +86,7 @@ public class Unit extends HeadedPawn this.def = defense; this.cdef = concealedDefense; this.mp = movementPoints; + mpLeft = mp; this.id = id; this.type = type; this.hasMoved = false; @@ -99,7 +102,7 @@ public class Unit extends HeadedPawn @Override public int getMovementPoints() { - return mp; + return mpLeft; } @Override @@ -201,10 +204,18 @@ public class Unit extends HeadedPawn } @Override + public void enter(int cost) + { + if (cost > mp) System.err.println("ERROR: Movement point exceeded: " + cost + "/" + mp + " please report"); + mpLeft -= cost; + } + + @Override public void move(int cost) { hasMoved = true; if (cost > mp) System.err.println("ERROR: Movement point exceeded: " + cost + "/" + mp + " please report"); + mpLeft = 0; } @Override @@ -216,6 +227,7 @@ public class Unit extends HeadedPawn @Override public void reset() { + mpLeft = mp; hasFired = false; hasMoved = false; } |