summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-20 10:55:39 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-20 10:55:39 +0200
commit9f6b1b1e85ed029673eef041e7f1be9e2356a780 (patch)
treecec58b9ac8ac99fb7aa0676930ef009fdc23f090 /core/src/ch/asynk/tankontank
parentad8eedcc8904c34ce35e13798bbb64d3096a46f8 (diff)
downloadRustAndDust-9f6b1b1e85ed029673eef041e7f1be9e2356a780.zip
RustAndDust-9f6b1b1e85ed029673eef041e7f1be9e2356a780.tar.gz
Paw,Unit: add boolean isA(PawnType type)
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-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