summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-17 15:18:32 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-17 15:18:32 +0100
commit793af2956fc0daa67585cae95489075788f72713 (patch)
treece372ecbd83dabceb01844b495a9eced3c6af7df /core/src/ch/asynk/tankontank/game
parentac99957ad09592e422f3e3cd0752f3e00d610ed5 (diff)
downloadRustAndDust-793af2956fc0daa67585cae95489075788f72713.zip
RustAndDust-793af2956fc0daa67585cae95489075788f72713.tar.gz
Pawn,Unit: add interface Pawn.PawnId, boolean isA(PawnId i)
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java
index bcb9e3c..468589e 100644
--- a/core/src/ch/asynk/tankontank/game/Unit.java
+++ b/core/src/ch/asynk/tankontank/game/Unit.java
@@ -27,7 +27,7 @@ public class Unit extends HeadedPawn
ARTILLERY
}
- public enum UnitId
+ public enum UnitId implements Pawn.PawnId
{
GE_AT_GUN("German Anti-Tank Gun"),
GE_INFANTRY("German Infantry"),
@@ -154,6 +154,12 @@ public class Unit extends HeadedPawn
}
@Override
+ public boolean isA(PawnId i)
+ {
+ return (id == i);
+ }
+
+ @Override
public boolean isA(PawnType t)
{
return (type == t);
@@ -168,9 +174,9 @@ public class Unit extends HeadedPawn
@Override
public boolean isHqOf(Pawn other)
{
- if ((id == UnitId.GE_PANZER_IV_HQ) && (((Unit)other).id == UnitId.GE_PANZER_IV)) return true;
- if ((id == UnitId.US_PERSHING_HQ) && (((Unit)other).id == UnitId.US_PERSHING)) return true;
- if ((id == UnitId.US_SHERMAN_HQ) && (((Unit)other).id == UnitId.US_SHERMAN)) return true;
+ if (isA(UnitId.GE_PANZER_IV_HQ) && other.isA(UnitId.GE_PANZER_IV)) return true;
+ if (isA(UnitId.US_PERSHING_HQ) && other.isA(UnitId.US_PERSHING)) return true;
+ if (isA(UnitId.US_SHERMAN_HQ) && other.isA(UnitId.US_SHERMAN)) return true;
return false;
}