summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-05 12:14:57 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-05 12:14:57 +0100
commit0f77f2ff98a8128e18044eb34d2c76234ebe8749 (patch)
tree5298694a8d13dc27f08e2c461fe4fc66ea091831 /core/src/ch/asynk/tankontank
parent3fdaaa05538525e828067e0eb4b91e7758ba023c (diff)
downloadRustAndDust-0f77f2ff98a8128e18044eb34d2c76234ebe8749.zip
RustAndDust-0f77f2ff98a8128e18044eb34d2c76234ebe8749.tar.gz
Pawn,Unit: add enter(int cost)
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Pawn.java1
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java14
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;
}