summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-08-11 20:23:07 +0200
committerTor Andersson <tor@ccxvii.net>2023-08-11 20:23:07 +0200
commit72d4f97f138f42762f45a67728a9f518ff73eb7e (patch)
treeb3deb110654d744923cc566ac717fa0dbb0c10a3
parent18bff30a0c1d0b533b49bee658703eca07d81ca7 (diff)
downloadrommel-in-the-desert-72d4f97f138f42762f45a67728a9f518ff73eb7e.tar.gz
Allow dismantling revealed minefields.
-rw-r--r--rules.js50
1 files changed, 25 insertions, 25 deletions
diff --git a/rules.js b/rules.js
index 391b9c2..0425651 100644
--- a/rules.js
+++ b/rules.js
@@ -6011,19 +6011,15 @@ function pay_bps(n) {
game.allied_bps -= n
}
-function count_secret_minefields() {
+function count_friendly_minefields() {
+ let net = friendly_buildup_network()
let n = 0
- if (is_axis_player()) {
- let network = game.buildup.axis_network
- for (let x of game.minefields[MF_AXIS])
- if (network[x])
- ++n
- } else {
- let network = game.buildup.allied_network
- for (let x of game.minefields[MF_ALLIED])
- if (network[x])
- ++n
- }
+ for (let x of friendly_minefields())
+ if (net[x] && !is_battle_hex(x))
+ ++n
+ for (let x of game.minefields[MF_VISIBLE])
+ if (net[x] && !is_battle_hex(x))
+ ++n
return n
}
@@ -6147,7 +6143,7 @@ states.spending_bps = {
if (game.selected < 0) {
if (game.month >= 11 && has_friendly_unit_in_raw_hex(MALTA))
gen_action_hex(MALTA)
- if (count_secret_minefields() >= 2 || bps >= 15)
+ if (count_friendly_minefields() >= 2 || bps >= 15)
gen_action('minefield')
if (bps >= 10)
gen_action('extra_supply_card')
@@ -6288,7 +6284,7 @@ states.minefield = {
prompt() {
view.prompt = `Buildup: Build a minefield.`
let mfs = friendly_minefields()
- if (mfs.length >= 2)
+ if (count_friendly_minefields() >= 2)
gen_action('dismantle')
if (available_bps() >= 15) {
let net = friendly_buildup_network()
@@ -6314,15 +6310,17 @@ states.dismantle1 = {
inactive: "buildup",
prompt() {
view.prompt = `Buildup: Dismantle first minefield to build a new one.`
- let mfs = friendly_minefields()
let net = friendly_buildup_network()
- for (let x of mfs)
- if (net[x])
+ for (let x of friendly_minefields())
+ if (net[x] && !is_battle_hex(x))
+ gen_action_hex(x)
+ for (let x of game.minefields[MF_VISIBLE])
+ if (net[x] && !is_battle_hex(x))
gen_action_hex(x)
},
hex(x) {
- let mfs = friendly_minefields()
- set_delete(mfs, x)
+ set_delete(friendly_minefields(), x)
+ set_delete(game.minefields[MF_VISIBLE], x)
game.state = 'dismantle2'
},
}
@@ -6331,15 +6329,17 @@ states.dismantle2 = {
inactive: "buildup",
prompt() {
view.prompt = `Buildup: Dismantle second minefield to build a new one.`
- let mfs = friendly_minefields()
let net = friendly_buildup_network()
- for (let x of mfs)
- if (net[x])
+ for (let x of friendly_minefields())
+ if (net[x] && !is_battle_hex(x))
+ gen_action_hex(x)
+ for (let x of game.minefields[MF_VISIBLE])
+ if (net[x] && !is_battle_hex(x))
gen_action_hex(x)
},
hex(x) {
- let mfs = friendly_minefields()
- set_delete(mfs, x)
+ set_delete(friendly_minefields(), x)
+ set_delete(game.minefields[MF_VISIBLE], x)
game.state = 'dismantle3'
},
}
@@ -6351,7 +6351,7 @@ states.dismantle3 = {
let mfs = friendly_minefields()
let net = friendly_buildup_network()
for (let x of all_hexes)
- if (net[x] && !is_battle_hex(x) && !set_has(mfs, x))
+ if (net[x] && !is_battle_hex(x) && !set_has(mfs, x) && !set_has(game.minefields[MF_VISIBLE], x))
gen_action_hex(x)
},
hex(x) {