summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js56
1 files changed, 48 insertions, 8 deletions
diff --git a/rules.js b/rules.js
index 886ae3a..52a0354 100644
--- a/rules.js
+++ b/rules.js
@@ -3,13 +3,18 @@
// TODO: fortress supply
// TODO: oasis supply
// TODO: raiders
-// TODO: reveal minefields
+// TODO: minefields
// TODO: gazala scenario
// TODO: legal pass withdrawal moves (reduce supply net, withdraw from fortress attack)
// TOOD: reveal/hide blocks (hexes)
// TODO: malta units?
+// TODO: group move from queue holding box to base
-// TODO: BUILDUP
+// TODO: redeployment
+// TODO: return for refit
+// TODO: replacements
+
+// RULES: may units redeploying out of battles cross enemy controlled hexsides?
// RULES: when is "fired" status cleared?
@@ -95,6 +100,14 @@ const FIREPOWER_MATRIX = [
[ SF, DF, DF, SF ],
]
+// Off board return to refit holding
+const AXIS_REFIT = 102
+const ALLIED_REFIT = 48
+
+// Off board reinforcements to engaged base!
+const AXIS_QUEUE = 127
+const ALLIED_QUEUE = 49
+
const EL_AGHEILA = 151
const ALEXANDRIA = 74
const BENGHAZI = 54
@@ -480,6 +493,18 @@ function friendly_base() {
return ALEXANDRIA
}
+function friendly_queue() {
+ if (is_axis_player())
+ return AXIS_QUEUE
+ return ALLIED_QUEUE
+}
+
+function friendly_refit() {
+ if (is_axis_player())
+ return AXIS_REFIT
+ return ALLIED_REFIT
+}
+
function update_presence() {
presence_invalid = false
presence_axis.fill(0)
@@ -3786,15 +3811,18 @@ function goto_buildup_supply_check() {
// Remember supply networks throughout buildup.
game.buildup = {
+ // redeployment network
axis_network: axis_supply_network().slice(),
allied_network: allied_supply_network().slice(),
+ // extra cards purchased
axis_cards: 0,
allied_cards: 0,
+ // remaining port capacity for sea redeployment
+ bardia: 2,
+ benghazi: 2,
+ tobruk: 5,
}
- debug_hexes("axis supply", supply_axis_network)
- debug_hexes("allied supply", supply_allied_network)
-
for_each_axis_unit_on_map(u => {
let x = unit_hex(u)
if (supply_axis_network[x])
@@ -3900,9 +3928,18 @@ states.buildup_reinforcements = {
function apply_reinforcements() {
let base = friendly_base()
+ let refitted = 0
let scheduled = 0
let early = 0
+ if (is_battle_hex(base))
+ base = friendly_queue()
+
+ for_each_friendly_unit_in_hex(friendly_refit(), u => {
+ set_unit_hex(u, base)
+ refitted++
+ })
+
for_each_friendly_unit_in_month(game.month, u => {
set_unit_hex(u, base)
scheduled++
@@ -3918,6 +3955,8 @@ function apply_reinforcements() {
}
log(`Reinforcements at #${base}:`)
+ if (refitted > 0)
+ log(`>${refitted} refitted`)
log(`>${scheduled} on schedule`)
log(`>${early} early`)
}
@@ -3963,6 +4002,7 @@ function end_buildup_spending() {
set_enemy_player()
goto_buildup_reinforcements()
} else {
+ delete game.buildup
goto_buildup_resupply()
}
}
@@ -4060,7 +4100,7 @@ states.axis_player_initiative = {
// === VICTORY CHECK ===
const EXIT_EAST_EDGE = [ 99, 123, 148 ] //, 172, 197 ]
-const EXIT_EAST_STASH = 49
+const EXIT_EAST = 172
function check_sudden_death_victory() {
// Supplied units that move beyond the map "edge" exit the map.
@@ -4070,14 +4110,14 @@ function check_sudden_death_victory() {
for_each_axis_unit(u => {
if (unit_hex(u) === x && is_unit_supplied(u)) {
log(`Exited the east map edge.`)
- set_unit_hex(u, EXIT_EAST_STASH)
+ set_unit_hex(u, EXIT_EAST)
}
})
}
let axis_exited = 0
for_each_axis_unit(u => {
- if (unit_hex(u) === EXIT_EAST_STASH)
+ if (unit_hex(u) === EXIT_EAST)
axis_exited++
})