summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/rustanddust/game/Unit.java73
-rw-r--r--core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java13
-rw-r--r--core/src/ch/asynk/rustanddust/game/battles/BattleTest.java13
-rw-r--r--core/src/ch/asynk/rustanddust/game/battles/Factory.java36
4 files changed, 42 insertions, 93 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Unit.java b/core/src/ch/asynk/rustanddust/game/Unit.java
index cdbcebc..9ccb621 100644
--- a/core/src/ch/asynk/rustanddust/game/Unit.java
+++ b/core/src/ch/asynk/rustanddust/game/Unit.java
@@ -27,7 +27,6 @@ public class Unit extends HeadedPawn
public enum UnitType implements Pawn.PawnType
{
HARD_TARGET,
- HARD_TARGET_HQ,
INFANTRY,
AT_GUN,
ARTILLERY
@@ -39,17 +38,14 @@ public class Unit extends HeadedPawn
GE_INFANTRY("German Infantry"),
GE_KINGTIGER("German King Tiger"),
GE_PANZER_IV("German Panzer IV"),
- GE_PANZER_IV_HQ("German Panzer IV HQ"),
GE_TIGER("German Tiger"),
GE_WESPE("German Wespe"),
US_AT_GUN("US Anti-Tank Gun"),
US_INFANTRY("US Infantry"),
US_PERSHING("US Pershing"),
- US_PERSHING_HQ("US Pershing HQ"),
US_PRIEST("US Priest"),
US_SHERMAN("US Sherman"),
- US_SHERMAN_HQ("US Sherman HQ"),
US_WOLVERINE("US Wolverine");
private String s;
@@ -64,6 +60,7 @@ public class Unit extends HeadedPawn
public int mpLeft;
public UnitType type;
public UnitId id;
+ public boolean hq;
public boolean ace;
private boolean hasMoved;
private boolean hasFired;
@@ -71,6 +68,7 @@ public class Unit extends HeadedPawn
protected Unit(Army army, String pawn, String head, TextureAtlas pawns, TextureAtlas overlays)
{
super(army, pawn, head, pawns, overlays);
+ hq = false;
ace = false;
}
@@ -87,28 +85,16 @@ public class Unit extends HeadedPawn
private void updateDescr()
{
if (cdef == -1)
- this.descr = id.toString() + (ace ? " Ace " : "") + " (" + rng + "-" + def + "-" + mp + ")";
+ this.descr = id.toString() + (hq ? " HQ " : "") + (ace ? " Ace " : "") + " (" + rng + "-" + def + "-" + mp + ")";
else
- this.descr = id.toString() + (ace ? " Ace " : "") + " (" + rng + "-" + def + "/" + cdef + "-" + mp + ")";
+ this.descr = id.toString() + (hq ? " HQ " : "") + (ace ? " Ace " : "") + " (" + rng + "-" + def + "/" + cdef + "-" + mp + ")";
}
- // hard tager
- public Unit(Army army, UnitId id, UnitType type, int range, int defense, int movementPoints, String unit, String head, TextureAtlas pawns, TextureAtlas overlays)
- {
- this(army, unit, head, pawns, overlays);
- this.rng = range;
- this.def = defense;
- this.cdef = -1;
- this.mp = movementPoints;
- this.id = id;
- this.type = type;
- commonSetup();
- }
-
- // soft tager
- public Unit(Army army, UnitId id, UnitType type, int range, int defense, int concealedDefense, int movementPoints, String unit, String head, TextureAtlas pawns, TextureAtlas overlays)
+ public Unit(Army army, UnitId id, UnitType type, boolean hq, boolean ace, int range, int defense, int concealedDefense, int movementPoints, String unit, String head, TextureAtlas pawns, TextureAtlas overlays)
{
this(army, unit, head, pawns, overlays);
+ this.hq = hq;
+ this.ace = ace;
this.rng = range;
this.def = defense;
this.cdef = concealedDefense;
@@ -133,13 +119,6 @@ public class Unit extends HeadedPawn
return ace;
}
- public void setAce(boolean ace)
- {
- this.ace = ace;
- updateDescr();
- enableOverlay(ACE, ace);
- }
-
@Override
public int getMovementPoints()
{
@@ -213,54 +192,36 @@ public class Unit extends HeadedPawn
@Override
public boolean isHardTarget()
{
- return (isA(UnitType.HARD_TARGET) || isA(UnitType.HARD_TARGET_HQ) || isA(UnitType.ARTILLERY));
+ return (isA(UnitType.HARD_TARGET) || isA(UnitType.ARTILLERY));
}
@Override
public boolean isHq()
{
- return isA(UnitType.HARD_TARGET_HQ);
+ return hq;
}
@Override
public boolean isHqOf(Pawn other)
{
- if (isA(UnitId.GE_PANZER_IV_HQ) && other.isA(UnitId.GE_PANZER_IV)) return true;
- if (isA(UnitId.US_PERSHING_HQ) && other.isA(UnitId.US_PERSHING)) return true;
- if (isA(UnitId.US_SHERMAN_HQ) && other.isA(UnitId.US_SHERMAN)) return true;
- return false;
+ return (isHq() && other.isA(id));
}
public void promote()
{
- if (isA(UnitId.GE_PANZER_IV))
- id = UnitId.GE_PANZER_IV_HQ;
- else if (isA(UnitId.US_PERSHING))
- id = UnitId.US_PERSHING_HQ;
- else if (isA(UnitId.US_SHERMAN))
- id = UnitId.US_SHERMAN_HQ;
- else
- return;
-
- type = UnitType.HARD_TARGET_HQ;
- enableOverlay(HQ, true);
- updateDescr();
+ setHq(true);
}
public void degrade()
{
- if (isA(UnitId.GE_PANZER_IV_HQ))
- id = UnitId.GE_PANZER_IV;
- else if (isA(UnitId.US_PERSHING_HQ))
- id = UnitId.US_PERSHING;
- else if (isA(UnitId.US_SHERMAN_HQ))
- id = UnitId.US_SHERMAN;
- else
- return;
+ setHq(false);
+ }
- type = UnitType.HARD_TARGET;
- enableOverlay(HQ, false);
+ private void setHq(boolean hq)
+ {
+ this.hq = hq;
updateDescr();
+ enableOverlay(HQ, hq);
}
@Override
diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java
index 5d97460..c103ca8 100644
--- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java
+++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java
@@ -176,23 +176,22 @@ public abstract class BattleCommon implements Battle
public void addReinforcement(Player player, Zone entryZone, UnitId unitId)
{
- addReinforcement(player, entryZone, unitId, false);
+ addReinforcement(player, entryZone, unitId, false, false);
}
public void addReinforcement(Player player, Zone entryZone, Zone exitZone, UnitId unitId)
{
- addReinforcement(player, entryZone, exitZone, unitId, false);
+ addReinforcement(player, entryZone, exitZone, unitId, false, false);
}
- public void addReinforcement(Player player, Zone entryZone, UnitId unitId, boolean ace)
+ public void addReinforcement(Player player, Zone entryZone, UnitId unitId, boolean hq, boolean ace)
{
- addReinforcement(player, entryZone, null, unitId, ace);
+ addReinforcement(player, entryZone, null, unitId, hq, ace);
}
- public void addReinforcement(Player player, Zone entryZone, Zone exitZone, UnitId unitId, boolean ace)
+ public void addReinforcement(Player player, Zone entryZone, Zone exitZone, UnitId unitId, boolean hq, boolean ace)
{
- Unit unit = factory.getUnit(unitId);
- unit.setAce(ace);
+ Unit unit = factory.getUnit(unitId, hq, ace);
player.addReinforcement(unit);
unitEntry.put(unit, entryZone);
if (exitZone != null)
diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java
index fc6f453..4772d9d 100644
--- a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java
+++ b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java
@@ -95,10 +95,10 @@ public class BattleTest extends BattleCommon
addExitZone(usExit);
currentPlayer = usPlayer;
- usPlayer.casualty(factory.getUnit(UnitId.US_SHERMAN_HQ));
+ usPlayer.casualty(factory.getUnit(UnitId.US_SHERMAN, true, false));
setUnit(map, usPlayer, UnitId.US_PRIEST, 7, 6, Orientation.SOUTH_EAST, usExit);
- setUnit(map, usPlayer, UnitId.US_SHERMAN, 8, 4, Orientation.SOUTH, true, usExit);
- setUnit(map, usPlayer, UnitId.US_SHERMAN_HQ, 7, 3, Orientation.SOUTH, usExit);
+ setUnit(map, usPlayer, UnitId.US_SHERMAN, 8, 4, Orientation.SOUTH, false, true, usExit);
+ setUnit(map, usPlayer, UnitId.US_SHERMAN, 7, 3, Orientation.SOUTH, true, false, usExit);
setUnit(map, usPlayer, UnitId.US_WOLVERINE, 11, 7, Orientation.SOUTH_EAST, usExit);
setUnit(map, usPlayer, UnitId.US_PERSHING, 6, 5, Orientation.SOUTH, usExit);
setUnit(map, usPlayer, UnitId.US_INFANTRY, 5, 3, Orientation.NORTH_EAST, usExit);
@@ -109,13 +109,12 @@ public class BattleTest extends BattleCommon
private Unit setUnit(Map map, Player player, UnitId unitId, int col, int row, Orientation orientation, Zone exitZone)
{
- return setUnit(map, player, unitId, col, row, orientation, false, exitZone);
+ return setUnit(map, player, unitId, col, row, orientation, false, false, exitZone);
}
- private Unit setUnit(Map map, Player player, UnitId unitId, int col, int row, Orientation orientation, boolean ace, Zone exitZone)
+ private Unit setUnit(Map map, Player player, UnitId unitId, int col, int row, Orientation orientation, boolean hq, boolean ace, Zone exitZone)
{
- Unit u = factory.getUnit(unitId);
- u.setAce(ace);
+ Unit u = factory.getUnit(unitId, hq, ace);
if (exitZone != null)
unitExit.put(u, exitZone);
map.setOnBoard(u, map.getHex(col, row), orientation);
diff --git a/core/src/ch/asynk/rustanddust/game/battles/Factory.java b/core/src/ch/asynk/rustanddust/game/battles/Factory.java
index 3203c3c..5dff7f6 100644
--- a/core/src/ch/asynk/rustanddust/game/battles/Factory.java
+++ b/core/src/ch/asynk/rustanddust/game/battles/Factory.java
@@ -86,62 +86,52 @@ public class Factory implements Board.TileBuilder, Disposable
return new Player(game, Army.GE, 10);
}
- public Unit getUnit(UnitId id)
+ public Unit getUnit(UnitId id, boolean hq, boolean ace)
{
Unit u = null;
UnitType ut = UnitType.HARD_TARGET;
- UnitType utHq = UnitType.HARD_TARGET_HQ;
switch(id) {
case GE_AT_GUN:
ut = UnitType.AT_GUN;
- u = new Unit(Army.GE, id, ut, 3, 8, 9, 1, "ge-at-gun", "ge-head", pawnsAtlas, pawnOverlaysAtlas);
+ u = new Unit(Army.GE, id, ut, hq, ace, 3, 8, 9, 1, "ge-at-gun", "ge-head", pawnsAtlas, pawnOverlaysAtlas);
break;
case GE_INFANTRY:
ut = UnitType.INFANTRY;
- u = new Unit(Army.GE, id, ut, 1, 7, 10, 1, "ge-infantry", "ge-head", pawnsAtlas, pawnOverlaysAtlas);
+ u = new Unit(Army.GE, id, ut, hq, ace, 1, 7, 10, 1, "ge-infantry", "ge-head", pawnsAtlas, pawnOverlaysAtlas);
break;
case GE_KINGTIGER:
- u = new Unit(Army.GE, id, ut, 3, 12, 1, "ge-kingtiger", "ge-head", pawnsAtlas, pawnOverlaysAtlas);
+ u = new Unit(Army.GE, id, ut, hq, ace, 3, 12, -1, 1, "ge-kingtiger", "ge-head", pawnsAtlas, pawnOverlaysAtlas);
break;
case GE_PANZER_IV:
- u = new Unit(Army.GE, id, ut, 2, 9, 2, "ge-panzer-iv", "ge-head", pawnsAtlas, pawnOverlaysAtlas);
- break;
- case GE_PANZER_IV_HQ:
- u = new Unit(Army.GE, id, utHq, 2, 9, 2, "ge-panzer-iv", "ge-head", pawnsAtlas, pawnOverlaysAtlas);
+ u = new Unit(Army.GE, id, ut, hq, ace, 2, 9, -1, 2, "ge-panzer-iv", "ge-head", pawnsAtlas, pawnOverlaysAtlas);
break;
case GE_TIGER:
- u = new Unit(Army.GE, id, ut, 3, 11, 1, "ge-tiger", "ge-head", pawnsAtlas, pawnOverlaysAtlas);
+ u = new Unit(Army.GE, id, ut, hq, ace, 3, 11, -1, 1, "ge-tiger", "ge-head", pawnsAtlas, pawnOverlaysAtlas);
break;
case GE_WESPE:
ut = UnitType.ARTILLERY;
- u = new Unit(Army.GE, id, ut, 5, 8, 1, "ge-wespe", "ge-head", pawnsAtlas, pawnOverlaysAtlas);
+ u = new Unit(Army.GE, id, ut, hq, ace, 5, 8, -1, 1, "ge-wespe", "ge-head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_AT_GUN:
ut = UnitType.AT_GUN;
- u = new Unit(Army.US, id, ut, 1, 7, 10, 1, "us-at-gun", "us-head", pawnsAtlas, pawnOverlaysAtlas);
+ u = new Unit(Army.US, id, ut, hq, ace, 1, 7, 10, 1, "us-at-gun", "us-head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_INFANTRY:
ut = UnitType.INFANTRY;
- u = new Unit(Army.US, id, ut, 1, 7, 10, 1, "us-infantry", "us-head", pawnsAtlas, pawnOverlaysAtlas);
+ u = new Unit(Army.US, id, ut, hq, ace, 1, 7, 10, 1, "us-infantry", "us-head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_PERSHING:
- u = new Unit(Army.US, id, ut, 3, 10, 2, "us-pershing", "us-head", pawnsAtlas, pawnOverlaysAtlas);
- break;
- case US_PERSHING_HQ:
- u = new Unit(Army.US, id, utHq, 3, 10, 2, "us-pershing", "us-head", pawnsAtlas, pawnOverlaysAtlas);
+ u = new Unit(Army.US, id, ut, hq, ace, 3, 10, -1, 2, "us-pershing", "us-head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_PRIEST:
ut = UnitType.ARTILLERY;
- u = new Unit(Army.US, id, ut, 5, 8, 1, "us-priest", "us-head", pawnsAtlas, pawnOverlaysAtlas);
+ u = new Unit(Army.US, id, ut, hq, ace, 5, 8, -1, 1, "us-priest", "us-head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_SHERMAN:
- u = new Unit(Army.US, id, ut, 2, 9, 2, "us-sherman", "us-head", pawnsAtlas, pawnOverlaysAtlas);
- break;
- case US_SHERMAN_HQ:
- u = new Unit(Army.US, id, utHq, 2, 9, 2, "us-sherman", "us-head", pawnsAtlas, pawnOverlaysAtlas);
+ u = new Unit(Army.US, id, ut, hq, ace, 2, 9, -1, 2, "us-sherman", "us-head", pawnsAtlas, pawnOverlaysAtlas);
break;
case US_WOLVERINE:
- u = new Unit(Army.US, id, ut, 3, 8, 3, "us-wolverine", "us-head", pawnsAtlas, pawnOverlaysAtlas);
+ u = new Unit(Army.US, id, ut, hq, ace, 3, 8, -1, 3, "us-wolverine", "us-head", pawnsAtlas, pawnOverlaysAtlas);
break;
}