summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r--core/src/ch/asynk/tankontank/game/Player.java8
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java9
2 files changed, 17 insertions, 0 deletions
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;