summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Pawn.java7
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java20
2 files changed, 19 insertions, 8 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java
index e623d3b..c21a088 100644
--- a/core/src/ch/asynk/tankontank/engine/Pawn.java
+++ b/core/src/ch/asynk/tankontank/engine/Pawn.java
@@ -22,6 +22,10 @@ import ch.asynk.tankontank.engine.gfx.animations.AnimationSequence;
public abstract class Pawn implements Moveable, Disposable
{
+ public interface PawnType
+ {
+ }
+
public class Attack
{
int distance;
@@ -46,9 +50,10 @@ public abstract class Pawn implements Moveable, Disposable
public abstract int getFlankSides();
public abstract int getAttackRangeFrom(Tile tile);
+ public abstract boolean isUnit();
+ public abstract boolean isA(PawnType type);
public abstract boolean isHq();
public abstract boolean isHqOf(Pawn other);
- public abstract boolean isUnit();
public abstract boolean isHardTarget();
public abstract boolean canMove();
diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java
index acb0201..56736d2 100644
--- a/core/src/ch/asynk/tankontank/game/Unit.java
+++ b/core/src/ch/asynk/tankontank/game/Unit.java
@@ -12,7 +12,7 @@ public class Unit extends HeadedPawn
{
public static final int DISABLED = 0;
- public enum UnitType
+ public enum UnitType implements Pawn.PawnType
{
HARD_TARGET,
HARD_TARGET_HQ,
@@ -121,15 +121,21 @@ public class Unit extends HeadedPawn
}
@Override
- public boolean isHq()
+ public boolean isUnit()
{
- return (type == UnitType.HARD_TARGET_HQ);
+ return true;
}
@Override
- public boolean isHardTarget()
+ public boolean isA(PawnType t)
{
- return ((type == UnitType.HARD_TARGET) || (type == UnitType.HARD_TARGET_HQ));
+ return (type == t);
+ }
+
+ @Override
+ public boolean isHq()
+ {
+ return (type == UnitType.HARD_TARGET_HQ);
}
@Override
@@ -142,9 +148,9 @@ public class Unit extends HeadedPawn
}
@Override
- public boolean isUnit()
+ public boolean isHardTarget()
{
- return true;
+ return ((type == UnitType.HARD_TARGET) || (type == UnitType.HARD_TARGET_HQ));
}
@Override