summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js53
1 files changed, 41 insertions, 12 deletions
diff --git a/rules.js b/rules.js
index 320b085..a6b1f2e 100644
--- a/rules.js
+++ b/rules.js
@@ -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()