From 86e4d41860b7aaeb37244fb09ccf07a2c2832627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 24 Sep 2014 22:28:28 +0200 Subject: Pawn,Unit,Army: implement isEnemy(Pawn) --- core/src/ch/asynk/tankontank/engine/Pawn.java | 1 + core/src/ch/asynk/tankontank/game/Army.java | 7 ++++++- core/src/ch/asynk/tankontank/game/Unit.java | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 8da9774..f5304c7 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -26,6 +26,7 @@ public abstract class Pawn extends Image implements Disposable public abstract int getMvt(); public abstract int roadMarch(); + public abstract boolean isEnemy(Pawn other); public Pawn(TextureRegion region, TextureAtlas atlas) { diff --git a/core/src/ch/asynk/tankontank/game/Army.java b/core/src/ch/asynk/tankontank/game/Army.java index 95b06e9..66c6b4f 100644 --- a/core/src/ch/asynk/tankontank/game/Army.java +++ b/core/src/ch/asynk/tankontank/game/Army.java @@ -2,5 +2,10 @@ package ch.asynk.tankontank.game; public enum Army { - GE, US + GE, US; + + public boolean isEnemy(Army other) + { + return (this != other); + } } diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java index 40fb68d..d9f0789 100644 --- a/core/src/ch/asynk/tankontank/game/Unit.java +++ b/core/src/ch/asynk/tankontank/game/Unit.java @@ -27,6 +27,12 @@ public class Unit extends Pawn return 1; } + @Override + public boolean isEnemy(Pawn other) + { + return army.isEnemy(((Unit) other).army); + } + // hard tager public Unit(Army army, boolean hq, int range, int defense, int movementPoints, TextureRegion region, TextureAtlas atlas) { -- cgit v1.1-2-g2b99