From 6a85509a168d7dff26424f0d8022ae33624cbaf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 20 Oct 2014 10:22:22 +0200 Subject: Pawn,Unit: add boolean isHardTarget() this fixes canMove/Rotate/Attack --- core/src/ch/asynk/tankontank/engine/Pawn.java | 1 + 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); } -- cgit v1.1-2-g2b99