From 47fa20f6ae602fcd3abfe571b11c0c96c49896cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 29 Oct 2014 09:30:32 +0100 Subject: Pawn: add boolean canBeAttacked(Pawn other) --- core/src/ch/asynk/tankontank/engine/Board.java | 1 + core/src/ch/asynk/tankontank/engine/Pawn.java | 1 + core/src/ch/asynk/tankontank/game/Unit.java | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 402a8e0..b1eb382 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -280,6 +280,7 @@ public abstract class Board implements Disposable targets.clear(); while (units.hasNext()) { Pawn target = units.next(); + if (!target.canBeAttacked(pawn)) continue; Tile to = target.getTile(); if (searchBoard.buildAttack(pawn, true, target, from.getCol(), from.getRow(), to.getCol(), to.getRow())) targets.add(target); diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 4d6299f..4439b31 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -62,6 +62,7 @@ public abstract class Pawn implements Moveable, Disposable public abstract boolean canRotate(); public abstract boolean canAttack(); public abstract boolean canAttack(Pawn other); + public abstract boolean canBeAttacked(Pawn other); public abstract boolean canAssistAttackWithoutLos(); public abstract void move(int cost); diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java index 11ab4e6..f950a1a 100644 --- a/core/src/ch/asynk/tankontank/game/Unit.java +++ b/core/src/ch/asynk/tankontank/game/Unit.java @@ -195,6 +195,12 @@ public class Unit extends HeadedPawn } @Override + public boolean canBeAttacked(Pawn other) + { + return true; + } + + @Override public void rotate(Orientation o) { hasMoved = true; -- cgit v1.1-2-g2b99