summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-02-18 11:27:55 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-02-18 11:27:55 +0100
commit57ba38f91476bf21ff72f387baaaa5577e31156d (patch)
treea9d408f8c32a6ac185a5aa2a6bc9367fa3533de9 /core
parent25d9117d0d5e2223184d1c6bb1ed2f753218733b (diff)
downloadRustAndDust-57ba38f91476bf21ff72f387baaaa5577e31156d.zip
RustAndDust-57ba38f91476bf21ff72f387baaaa5577e31156d.tar.gz
Map: engagement code refactoring
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java24
1 files changed, 11 insertions, 13 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 3d16420..c19ee62 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -467,7 +467,7 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS
}
}
- private boolean resolveFight(Unit unit, final Unit target, boolean mayReroll)
+ private boolean resolveFight(Unit unit, final Unit target, Engagement e)
{
int d1 = d6();
int d2 = d6();
@@ -476,11 +476,14 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS
int dice = d1 + d2;
int distance = 0;
+ boolean mayReroll = false;
boolean night = (meteorology.day == Meteorology.Day.NIGHT);
boolean flankAttack = false;
boolean terrainBonus = true;
- for (Pawn assist : activatedUnits) {
+ for (Unit assist : activatedUnits) {
+ if (assist.isAce())
+ mayReroll = true;
if (assist.isFlankAttack())
flankAttack = true;
if (assist.isA(Unit.UnitType.INFANTRY))
@@ -531,24 +534,19 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS
}
}
- engagement.set(d1, d2, d3, d4, cnt, flk, def, tdf, wdf);
- engagement.success = success;
- engagement.attacker = ctrl.player.army;
- engagement.defender = ctrl.opponent.army;
- ctrl.hud.engagementSummary(engagement, ctrl.cfg.fxVolume);
+ e.set(d1, d2, d3, d4, cnt, flk, def, tdf, wdf);
+ e.success = success;
+ e.attacker = ctrl.player.army;
+ e.defender = ctrl.opponent.army;
+ ctrl.hud.engagementSummary(e, ctrl.cfg.fxVolume);
return success;
}
public boolean engageUnit(Unit unit, final Unit target)
{
- boolean mayReroll = false;
- for (Unit assist : activatedUnits) {
- if (assist.isAce())
- mayReroll = true;
- }
- boolean success = resolveFight(unit, target, mayReroll);
+ boolean success = resolveFight(unit, target, engagement);
breakUnits.clear();
for (Unit u : activatedUnits) {