diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-08-06 12:40:18 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-17 13:11:26 +0100 |
commit | 24c558ffceb514745f06998726799c67f30c5806 (patch) | |
tree | b5cbc37c62b64491d5b2d87b29f7bbac8121d60e | |
parent | 8928a46b8869ef65fff4bd2a5d77504eeb532c8d (diff) | |
download | rommel-in-the-desert-24c558ffceb514745f06998726799c67f30c5806.tar.gz |
Malta reinforcements.
-rw-r--r-- | rules.js | 53 |
1 files changed, 41 insertions, 12 deletions
@@ -547,17 +547,25 @@ function friendly_refit() { function update_presence() { presence_invalid = false presence_axis.fill(0) - for (let u = first_axis_unit; u <= last_axis_unit; ++u) - if (is_unit_disrupted(u)) - presence_axis[unit_hex(u)] |= 1 - else - presence_axis[unit_hex(u)] |= 2 + for (let u = first_axis_unit; u <= last_axis_unit; ++u) { + let x = unit_hex(u) + if (x >= first_hex && x <= last_hex) { + if (is_unit_disrupted(u)) + presence_axis[x] |= 1 + else + presence_axis[x] |= 2 + } + } presence_allied.fill(0) - for (let u = first_allied_unit; u <= last_allied_unit; ++u) - if (is_unit_disrupted(u)) - presence_allied[unit_hex(u)] |= 1 - else - presence_allied[unit_hex(u)] |= 2 + for (let u = first_allied_unit; u <= last_allied_unit; ++u) { + let x = unit_hex(u) + if (x >= first_hex && x <= last_hex) { + if (is_unit_disrupted(u)) + presence_allied[x] |= 1 + else + presence_allied[x] |= 2 + } + } } function count_friendly_units_in_hex(x) { @@ -568,13 +576,17 @@ function count_friendly_units_in_hex(x) { return n } -function has_friendly_unit_in_month(month) { +function has_friendly_unit_in_raw_hex(x) { for (let u = first_friendly_unit; u <= last_friendly_unit; ++u) - if (unit_hex(u) === hexdeploy + month) + if (unit_hex(u) === x) return true return false } +function has_friendly_unit_in_month(month) { + return has_friendly_unit_in_raw_hex(hexdeploy + month) +} + function for_each_friendly_unit_in_month(month, fn) { for (let u = first_friendly_unit; u <= last_friendly_unit; ++u) if (unit_hex(u) === hexdeploy + month) @@ -4727,6 +4739,8 @@ states.spending_bps = { if (!is_unit_disrupted(u)) gen_action_unit(u) }) + if (game.month >= 11 && has_friendly_unit_in_raw_hex(MALTA)) + gen_action_hex(MALTA) } else { gen_action_unit(game.selected) gen_spending_bps() @@ -4767,6 +4781,20 @@ states.spending_bps = { set_unit_hex(pop_selected(), friendly_refit()) }, hex(to) { + if (to === MALTA) { + push_undo() + log(`Malta Group arrived.`) + log(`Axis Resupply dropped to 2.`) + let base = friendly_base() + if (is_battle_hex(base)) + base = friendly_queue() + for_each_friendly_unit_in_hex(MALTA, u => { + set_unit_hex(u, base) + }) + game.malta = 1 + return + } + game.changed = 1 let who = game.selected let from = unit_hex(who) @@ -4800,6 +4828,7 @@ states.spending_bps = { }, end_buildup() { delete game.changed + game.selected = -1 clear_undo() let n = available_bps() |