summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-12-01 01:34:41 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-12-01 01:34:41 +0100
commit4b73055612c8a15fcd85482a8fa81185c01a2731 (patch)
tree574f5e248cc2d70dfe38c710dccac31c668ea4fd /core/src
parent229beb7a00997510fc232f38b5ebf82e33470a12 (diff)
downloadRustAndDust-4b73055612c8a15fcd85482a8fa81185c01a2731.zip
RustAndDust-4b73055612c8a15fcd85482a8fa81185c01a2731.tar.gz
Map: do compute engagement numbers whatever the die are
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java66
1 files changed, 32 insertions, 34 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 1e4aef3..3123355 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -347,49 +347,47 @@ public abstract class Map extends Board
int d2 = d6();
int die = d1 + d2;
- boolean success = false;
- if (die == 2) {
- engagement.set(d1, d2, 0, 0, 0, 0, 0);
- success = false;
- } else if (die == 12) {
- engagement.set(d1, d2, 0, 0, 0, 0, 0);
- success = true;
- } else {
-
- int distance = 0;
- boolean night = (meteorology.day == Meteorology.Day.NIGHT);
- boolean flankAttack = false;
- boolean terrainBonus = true;
-
- for (Pawn assist : activatedUnits) {
- if (assist.isFlankAttack())
- flankAttack = true;
- if (assist.isA(Unit.UnitType.INFANTRY))
- terrainBonus = false;
- if (night) {
- int d = distance(assist.getTile(), target.getTile());
- if (d > distance)
- distance = d;
- }
+ int distance = 0;
+ boolean night = (meteorology.day == Meteorology.Day.NIGHT);
+ boolean flankAttack = false;
+ boolean terrainBonus = true;
+
+ for (Pawn assist : activatedUnits) {
+ if (assist.isFlankAttack())
+ flankAttack = true;
+ if (assist.isA(Unit.UnitType.INFANTRY))
+ terrainBonus = false;
+ if (night) {
+ int d = distance(assist.getTile(), target.getTile());
+ if (d > distance)
+ distance = d;
}
+ }
- int cnt = activatedUnits.size();
- int def = target.getDefense(unit.getTile());
- int flk = (flankAttack ? Unit.FLANK_ATTACK_BONUS : 0);
- int tdf = (terrainBonus ? target.getTile().defense() : 0);
- int wdf = 0;
- if (night) {
+ int cnt = activatedUnits.size();
+ int def = target.getDefense(unit.getTile());
+ int flk = (flankAttack ? Unit.FLANK_ATTACK_BONUS : 0);
+ int tdf = (terrainBonus ? target.getTile().defense() : 0);
+ int wdf = 0;
+ if (night) {
if (distance > 3)
wdf = 3;
else if (distance > 2)
wdf = 2;
else if (distance > 1)
wdf = 1;
- }
- int s1 = (die + cnt + flk);
- int s2 = (def + tdf + wdf);
+ }
+ int s1 = (die + cnt + flk);
+ int s2 = (def + tdf + wdf);
+ engagement.set(d1, d2, cnt, flk, def, tdf, wdf);
+
+ boolean success = false;
+ if (die == 2) {
+ success = false;
+ } else if (die == 12) {
+ success = true;
+ } else {
success = (s1 >= s2);
- engagement.set(d1, d2, cnt, flk, def, tdf, wdf);
}
engagement.success = success;