diff options
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/Player.java | 8 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Unit.java | 9 | ||||
-rw-r--r-- | core/test/ch/asynk/tankontank/Helpers.java | 1 |
4 files changed, 19 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index ef91544..83cd642 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -46,6 +46,7 @@ public abstract class Pawn implements Drawable, Disposable public abstract int getAttackRangeFrom(Tile tile); public abstract boolean isHq(); + public abstract boolean isHqOf(Pawn other); public abstract boolean isUnit(); public abstract boolean isEnemy(Pawn other); diff --git a/core/src/ch/asynk/tankontank/game/Player.java b/core/src/ch/asynk/tankontank/game/Player.java index ca8716c..5646311 100644 --- a/core/src/ch/asynk/tankontank/game/Player.java +++ b/core/src/ch/asynk/tankontank/game/Player.java @@ -110,6 +110,14 @@ public class Player implements Drawable, Disposable return ((Unit) pawn).isEnemy(army); } + public boolean canPromote(Pawn pawn) + { + if (pawn.isHq()) return false; + for (Pawn p: casualties) + if (p.isHqOf(pawn)) return true; + return false; + } + public void setPosition(float x, float y) { flag.setPosition(x, y); diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java index a20891b..bae5fd8 100644 --- a/core/src/ch/asynk/tankontank/game/Unit.java +++ b/core/src/ch/asynk/tankontank/game/Unit.java @@ -129,6 +129,15 @@ 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; + return false; + } + + @Override public boolean isUnit() { return true; diff --git a/core/test/ch/asynk/tankontank/Helpers.java b/core/test/ch/asynk/tankontank/Helpers.java index 518ccaf..c0cf64c 100644 --- a/core/test/ch/asynk/tankontank/Helpers.java +++ b/core/test/ch/asynk/tankontank/Helpers.java @@ -29,6 +29,7 @@ public class Helpers public int getAttackRangeFrom(Tile tile) { return 3; } public boolean isHq() { return true; } + public boolean isHqOf(Pawn other) { return true; } public boolean isUnit() { return true; } public boolean isEnemy(Pawn other) { return true; } |