diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-20 10:22:22 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-20 10:22:22 +0200 |
commit | 6a85509a168d7dff26424f0d8022ae33624cbaf7 (patch) | |
tree | 5363fcb197e4ef76f7520af32372706458df2de6 /core | |
parent | c5fef55dfb3452c86e3c7a3c54f09263ce3c7cff (diff) | |
download | RustAndDust-6a85509a168d7dff26424f0d8022ae33624cbaf7.zip RustAndDust-6a85509a168d7dff26424f0d8022ae33624cbaf7.tar.gz |
Pawn,Unit: add boolean isHardTarget() this fixes canMove/Rotate/Attack
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 1 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Unit.java | 12 |
2 files changed, 10 insertions, 3 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index eb5953f..e623d3b 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -49,6 +49,7 @@ public abstract class Pawn implements Moveable, Disposable public abstract boolean isHq(); public abstract boolean isHqOf(Pawn other); public abstract boolean isUnit(); + public abstract boolean isHardTarget(); public abstract boolean canMove(); public abstract boolean canRotate(); diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java index f047de4..822472a 100644 --- a/core/src/ch/asynk/tankontank/game/Unit.java +++ b/core/src/ch/asynk/tankontank/game/Unit.java @@ -127,6 +127,12 @@ public class Unit extends HeadedPawn } @Override + public boolean isHardTarget() + { + return ((type == UnitType.HARD_TARGET) || (type == UnitType.HARD_TARGET_HQ)); + } + + @Override public boolean isHqOf(Pawn other) { if ((id == UnitId.GE_PANZER_IV_HQ) && (((Unit)other).id == UnitId.GE_PANZER_IV)) return true; @@ -144,21 +150,21 @@ public class Unit extends HeadedPawn @Override public boolean canRotate() { - if (type == UnitType.HARD_TARGET) return !hasMoved; + if (isHardTarget()) return !hasMoved; return (!hasMoved && !hasFired); } @Override public boolean canMove() { - if (type == UnitType.HARD_TARGET) return !hasMoved; + if (isHardTarget()) return !hasMoved; return (!hasMoved && !hasFired); } @Override public boolean canAttack() { - if (type == UnitType.HARD_TARGET) return !hasFired; + if (isHardTarget()) return !hasFired; return (!hasMoved && !hasFired); } |