summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-19 17:07:57 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-19 17:07:57 +0100
commitcd0986c06c49b4329e80d18be3f3d432b492e063 (patch)
tree792ea3c9b91f3f5a6b101ea02ff21cdcbcbfe459 /core/src/ch/asynk/tankontank/game
parent61a41c984078fc8880ab6796765439b3cc1e4b7f (diff)
downloadRustAndDust-cd0986c06c49b4329e80d18be3f3d432b492e063.zip
RustAndDust-cd0986c06c49b4329e80d18be3f3d432b492e063.tar.gz
Map: add defense bonus if night fight
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 253b2e7..35f0f8e 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -260,6 +260,8 @@ public abstract class Map extends Board
return true;
} else {
+ int distance = 0;
+ boolean night = (meteorology.day == Meteorology.Day.NIGHT);
boolean flankAttack = false;
boolean terrainBonus = true;
@@ -268,15 +270,31 @@ public abstract class Map extends Board
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 = activatedPawns.size();
int def = target.getDefense(pawn.getTile());
int flk = (flankAttack ? Unit.FLANK_ATTACK_BONUS : 0);
int tdf = (terrainBonus ? pawn.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;
+ }
- pawn.engagement.calculus = "2D6(" + d1 + " + " + d2 + ") + " + cnt + " + " + flk + " >= " + def + " + " +tdf;
- return ((dice + cnt + flk) >= (def + tdf));
+ pawn.engagement.calculus = "2D6(" + d1 + " + " + d2 + ") + " + cnt + " + " + flk + " >= " + def + " + " + tdf + " + " + wdf;
+ if (night)
+ pawn.engagement.calculus += " + " + wdf;
+ return ((dice + cnt + flk) >= (def + tdf + wdf));
}
}