From 22aa4e63be0716c704a129d130855bf7b7f6e5c0 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 12 Aug 2023 01:07:51 +0200 Subject: Allow dismantling a single minefield without placing a new one. --- rules.js | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 0425651..539ed03 100644 --- a/rules.js +++ b/rules.js @@ -6143,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_friendly_minefields() >= 2 || bps >= 15) + if (count_friendly_minefields() >= 1 || bps >= 15) gen_action('minefield') if (bps >= 10) gen_action('extra_supply_card') @@ -6284,7 +6284,7 @@ states.minefield = { prompt() { view.prompt = `Buildup: Build a minefield.` let mfs = friendly_minefields() - if (count_friendly_minefields() >= 2) + if (count_friendly_minefields() >= 1) gen_action('dismantle') if (available_bps() >= 15) { let net = friendly_buildup_network() @@ -6295,7 +6295,10 @@ states.minefield = { }, dismantle() { push_undo() - game.state = 'dismantle1' + if (count_friendly_minefields() >= 2) + game.state = 'dismantle1' + else + game.state = 'dismantle0' }, hex(x) { let mfs = friendly_minefields() @@ -6306,6 +6309,25 @@ states.minefield = { } } +states.dismantle0 = { + inactive: "buildup", + prompt() { + view.prompt = `Buildup: Dismantle minefield.` + let net = friendly_buildup_network() + 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) { + set_delete(friendly_minefields(), x) + set_delete(game.minefields[MF_VISIBLE], x) + game.state = 'spending_bps' + }, +} + states.dismantle1 = { inactive: "buildup", prompt() { @@ -6347,7 +6369,7 @@ states.dismantle2 = { states.dismantle3 = { inactive: "buildup", prompt() { - view.prompt = `Buildup: Build a new minefield.` + view.prompt = `Buildup: Build a new minefield at no cost.` let mfs = friendly_minefields() let net = friendly_buildup_network() for (let x of all_hexes) -- cgit v1.2.3