diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 94 |
1 files changed, 83 insertions, 11 deletions
@@ -1,17 +1,14 @@ "use strict" -// TODO: MINEFIELDS -// TODO: create minefields -// TODO: tear down 2 minefields to create new minefield -// TODO: track minefields to be revealed when moved through -// TODO: reveal minefields at end of movement - // TODO: legal pass withdrawal moves (reduce supply net, withdraw from fortress attack) // TODO: fortress combat in pass turns (must withdraw) // TODO: log summaries (deploy, rebuild, move, etc) // TODO: put initial deployment stack somewhere more accessible (spread out along the top?) +// UI: separate colors for secret and visible minefields +// UI: basic turn - skip move - direct to combat + // TODO: undo push/clear // ERRATA: forbid single-group regroup moves or convert to group moves after the fact, @@ -1768,7 +1765,7 @@ function find_valid_regroup_destinations(from, rommel) { // === MINEFIELDS === function visit_hex(x) { - let mf_enemy = (game.active === AXIS) ? MF_AXIS : MF_ALLIED + let mf_enemy = (game.active === AXIS) ? MF_ALLIED : MF_AXIS if (set_has(game.minefields[mf_enemy], x)) set_add(game.minefields[MF_REVEAL], x) console.log("VISIT", x, hex_name[x]) @@ -3852,7 +3849,7 @@ function is_fortress_defensive_fire() { function is_minefield_offensive_fire() { if ((game.state === 'battle_fire' && is_active_player()) || (game.state === 'probe_fire' && is_passive_player())) { - if (set_has(game.minefields)) { + if (set_has(game.minefields[MF_VISIBLE])) { // DD advantage is lost if the defender initiated combat if (is_axis_player()) return set_has(game.allied_hexes, game.battle) @@ -5010,10 +5007,85 @@ function end_buildup_spending() { } } +function friendly_minefields() { + return is_axis_player() ? game.minefields[MF_AXIS] : game.minefields[MF_ALLIED] +} + +function friendly_buildup_network() { + return is_axis_player() ? game.buildup.axis_network : game.buildup.allied_network +} + states.minefield = { prompt() { - view.prompt = `Buildup: Build a minefield. (TODO!)` - // Tear down two existing, or pay 15 + view.prompt = `Buildup: Build a minefield.` + let mfs = friendly_minefields() + let net = friendly_buildup_network() + if (mfs.length >= 2) + gen_action('dismantle') + for (let x of all_hexes) + if (net[x] && !is_battle_hex(x) && !set_has(mfs, x)) + gen_action_hex(x) + }, + dismantle() { + push_undo() + game.state = 'dismantle1' + }, + hex(x) { + let mfs = friendly_minefields() + log(`Built minefield.`) + pay_bps(15) + set_add(mfs, x) + game.state = 'spending_bps' + } +} + +states.dismantle1 = { + 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]) + gen_action_hex(x) + }, + hex(x) { + let mfs = friendly_minefields() + set_delete(mfs, x) + game.state = 'dismantle2' + }, +} + +states.dismantle2 = { + 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]) + gen_action_hex(x) + }, + hex(x) { + let mfs = friendly_minefields() + set_delete(mfs, x) + game.state = 'dismantle3' + }, +} + +states.dismantle3 = { + prompt() { + view.prompt = `Buildup: Build a new minefield.` + 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)) + gen_action_hex(x) + }, + hex(x) { + let mfs = friendly_minefields() + log(`Dismantled minefields.`) + log(`Built minefield.`) + set_add(mfs, x) + game.state = 'spending_bps' }, } @@ -5319,7 +5391,7 @@ function begin_game() { if (game.scenario === "Crusader") { game.phasing = ALLIED - set_add(game.minefields, TOBRUK) + set_add(game.minefields[MF_VISIBLE], TOBRUK) } if (game.scenario === "Gazala") { |