summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Pawn.java1
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java46
-rw-r--r--core/test/ch/asynk/tankontank/Helpers.java1
3 files changed, 44 insertions, 4 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java
index 949803e..6243cf6 100644
--- a/core/src/ch/asynk/tankontank/engine/Pawn.java
+++ b/core/src/ch/asynk/tankontank/engine/Pawn.java
@@ -34,6 +34,7 @@ public abstract class Pawn implements Drawable, Disposable
public abstract boolean isUnit();
public abstract boolean isEnemy(Pawn other);
public abstract boolean canMove();
+ public abstract boolean canRotate();
public abstract boolean canAttack();
public abstract boolean canAttack(Pawn other);
public abstract int getAngleOfAttack();
diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java
index 0a066e0..b5924f3 100644
--- a/core/src/ch/asynk/tankontank/game/Unit.java
+++ b/core/src/ch/asynk/tankontank/game/Unit.java
@@ -18,6 +18,15 @@ public class Unit extends HeadedPawn
public boolean hq;
public boolean ht;
public Army army;
+ private boolean hasMoved;
+ private boolean hasFired;
+
+ public Unit(TextureAtlas atlas, String pawn, String head)
+ {
+ super(atlas, pawn, head);
+ hasMoved = false;
+ hasFired = false;
+ }
@Override
public int getMovementPoints()
@@ -63,17 +72,24 @@ public class Unit extends HeadedPawn
}
@Override
+ public boolean canRotate()
+ {
+ if (ht) return !hasMoved;
+ return (!hasMoved && !hasFired);
+ }
+
+ @Override
public boolean canMove()
{
- // TODO
- return true;
+ if (ht) return !hasMoved;
+ return (!hasMoved && !hasFired);
}
@Override
public boolean canAttack()
{
- // TODO
- return true;
+ if (ht) return !hasFired;
+ return (!hasMoved && !hasFired);
}
@Override
@@ -82,6 +98,28 @@ public class Unit extends HeadedPawn
return isEnemy(other);
}
+ public void fire()
+ {
+ hasFired = true;
+ }
+
+ public void rotate()
+ {
+ hasMoved = true;
+ }
+
+ public void move(int cost)
+ {
+ hasMoved = true;
+ if (cost > mp) System.err.println("Movement point exceeded: " + cost + "/" + mp);
+ }
+
+ public void reset()
+ {
+ hasFired = false;
+ hasMoved = false;
+ }
+
// hard tager
public Unit(Army army, boolean hq, int range, int defense, int movementPoints, TextureAtlas atlas, String unit, String head)
{
diff --git a/core/test/ch/asynk/tankontank/Helpers.java b/core/test/ch/asynk/tankontank/Helpers.java
index 731aaa2..ab8e5db 100644
--- a/core/test/ch/asynk/tankontank/Helpers.java
+++ b/core/test/ch/asynk/tankontank/Helpers.java
@@ -28,6 +28,7 @@ public class Helpers
public boolean isUnit() { return true; }
public boolean isEnemy(Pawn other) { return true; }
public boolean canMove() { return true; }
+ public boolean canRotate() { return true; }
public boolean canAttack() { return true; }
public boolean canAttack(Pawn other) { return true; }
public int getAngleOfAttack() { return 0; }