summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js36
1 files changed, 32 insertions, 4 deletions
diff --git a/rules.js b/rules.js
index 0491dbb..3f4afab 100644
--- a/rules.js
+++ b/rules.js
@@ -4,6 +4,7 @@
// TODO: fortress supply
// TODO: fortress battles mandatory combat!
+// TODO: oasis supply
// TODO: legal pass withdrawal moves
// TODO: raiders
@@ -27,6 +28,8 @@
// RULES: disrupted units routed again in second enemy turn, will they still recover?
// assume yes, easy to change (remove from game.recover set if routed)
+// RULES: reveal minefields moved through (but not stopped at)?
+
const max = Math.max
const min = Math.min
const abs = Math.abs
@@ -2621,7 +2624,7 @@ function is_assault_battle() {
return set_has(game.assault_battles, game.battle)
}
-function is_fortress_defender() {
+function is_fortress_defensive_fire() {
if ((game.state === 'battle_fire' && is_passive_player()) || (game.state === 'probe_fire' && is_active_player())) {
if (game.battle === BENGHAZI)
return game.benghazi === game.active
@@ -2633,17 +2636,29 @@ function is_fortress_defender() {
return false
}
+function is_minefield_offensive_fire() {
+ if ((game.state === 'battle_fire' && is_active_player()) || (game.state === 'probe_fire' && is_passive_player())) {
+ if (set_has(game.revealed_minefields) {
+ // DD advantage is lost if the defender initiated combat
+ if (is_axis_player()
+ return set_has(game.allied_hexes, game.battle)
+ else
+ return set_has(game.axis_hexes, game.battle)
+ }
+ }
+ return false
+}
+
function roll_battle_fire(who, tc) {
let fc = unit_class(who)
let cv = unit_cv(who)
- // Double dice during assault!
+ // Double dice during assault and non-armor defenders in fortress!
if (is_assault_battle())
cv += cv
- else if (fc !== ARMOR && is_fortress_defender())
+ else if (fc !== ARMOR && is_fortress_defensive_fire())
cv += cv
- console.log("FIRE", unit_name(who), cv)
let fp = FIREPOWER_MATRIX[fc][tc]
let result = []
let total = 0
@@ -2653,6 +2668,11 @@ function roll_battle_fire(who, tc) {
if (roll >= fp)
++total
}
+
+ // Double defense in minefields!
+ if (is_minefield_offensive_fire())
+ total = total / 2
+
game.flash = `${unit_name(who)} fired ${firepower_name[fp]} at ${class_name[tc]}: ` + result.join(", ")
log(game.flash)
return total
@@ -2707,6 +2727,13 @@ function apply_battle_fire(tc) {
}
if (done) {
set_enemy_player()
+
+ // round down half-hits from double defense
+ game.hits[0] |= 0
+ game.hits[1] |= 0
+ game.hits[2] |= 0
+ game.hits[3] |= 0
+
if (game.state === 'battle_fire')
game.state = 'battle_hits'
else
@@ -3729,6 +3756,7 @@ exports.setup = function (seed, scenario, options) {
axis_minefields: [],
allied_minefields: [],
+ revealed_minefields: [],
// fortress control
bardia: ALLIED,