summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js71
1 files changed, 32 insertions, 39 deletions
diff --git a/rules.js b/rules.js
index 1abe86b..ead708f 100644
--- a/rules.js
+++ b/rules.js
@@ -145,6 +145,8 @@ const MERSA_BREGA = 152
const JALO_OASIS = 204
const JARABUB_OASIS = 187
const SIWA_OASIS = 213
+const SIDI_OMAR = 89
+const SOLLUM = 65
const BARDIA_FT_CAPUZZO = 122
@@ -160,12 +162,9 @@ const MF_ALLIED = 1
const MF_VISIBLE = 2
const MF_REVEAL = 3
-const region_egypt = regions["Egypt"]
-const region_egypt_and_libya = regions["Libya"].concat(regions["Egypt"])
-const region_libya_and_sidi_omar = regions["Libya"].concat(regions["Sidi Omar"])
-const region_libya_and_sidi_omar_and_sollum_except_tobruk = regions["Libya"].concat(regions["Sidi Omar"]).concat(regions["Sollum"]).filter(r => r !== TOBRUK)
-const region_egypt_and_tobruk = regions["Egypt"].concat(regions["Tobruk"])
-const region_libya_except_tobruk = regions["Libya"].filter(r => r !== TOBRUK)
+const EGYPT = regions.Egypt
+const LIBYA = regions.Libya
+const LIBYA_NO_TOBRUK = LIBYA.filter(r => r !== TOBRUK)
function calc_distance(a, b) {
let ax = a % hexw, ay = (a / hexw)|0, az = -ax - ay
@@ -5540,10 +5539,13 @@ function goto_buildup_point_determination() {
function goto_buildup_discard() {
log_h2(game.active + " Buildup")
- game.state = 'buildup_discard'
let hand = player_hand()
- if (hand[REAL] + hand[DUMMY] === 0)
+ if (hand[REAL] + hand[DUMMY] === 0) {
goto_buildup_reinforcements()
+ } else {
+ game.state = 'buildup_discard'
+ game.summary = 0
+ }
}
states.buildup_discard = {
@@ -5557,12 +5559,13 @@ states.buildup_discard = {
},
dummy_card() {
push_undo()
- log(game.active + " discarded dummy supply.")
let hand = player_hand()
hand[DUMMY]--
+ game.summary++
},
next() {
clear_undo()
+ log(`${game.active} discarded ${game.summary} dummy supply.`)
goto_buildup_reinforcements()
},
}
@@ -5972,10 +5975,7 @@ function end_buildup_spending() {
set_enemy_player()
goto_buildup_discard()
} else {
- if (is_pregame_buildup())
- end_pregame_buildup()
- else
- goto_buildup_resupply()
+ goto_buildup_resupply()
}
}
@@ -6065,21 +6065,14 @@ states.dismantle3 = {
},
}
-function end_pregame_buildup() {
- if (game.buildup.axis_cards > 0 || game.buildup.allied_cards > 0) {
- log_h2("Resupply")
- deal_axis_supply_cards(game.buildup.axis_cards)
- deal_allied_supply_cards(game.buildup.allied_cards)
- }
- game.buildup = null
- goto_initial_supply_cards()
-}
-
function goto_buildup_resupply() {
// Per-scenario allotment
let axis_resupply = (game.month <= 10 || game.malta) ? 2 : 3
let allied_resupply = 3
+ if (is_pregame_buildup())
+ axis_resupply = allied_resupply = 0
+
log_h2("Resupply")
log(`Shuffled supply cards.`)
shuffle_cards()
@@ -6333,10 +6326,7 @@ function end_free_deployment() {
} else {
game.selected = -1
game.summary = null
- if (is_pregame_buildup())
- goto_pregame_buildup()
- else
- goto_initial_supply_cards()
+ goto_initial_supply_cards()
}
}
@@ -6398,7 +6388,10 @@ function begin_game() {
// No buildup first month
// No initiative first month
- goto_player_turn()
+ if (is_pregame_buildup())
+ goto_pregame_buildup()
+ else
+ goto_player_turn()
}
// === SETUP ===
@@ -6473,8 +6466,8 @@ const SCENARIOS = {
"1940": {
start: 1,
end: 6,
- axis_deployment: sort_deployment_for_axis(region_libya_and_sidi_omar),
- allied_deployment: sort_deployment_for_allied(region_egypt),
+ axis_deployment: sort_deployment_for_axis([...LIBYA, SIDI_OMAR]),
+ allied_deployment: sort_deployment_for_allied(EGYPT),
axis_initial_supply: 6,
allied_initial_supply: 3,
},
@@ -6482,23 +6475,23 @@ const SCENARIOS = {
start: 1,
end: 10,
axis_deployment: [],
- allied_deployment: sort_deployment_for_allied(region_egypt_and_libya),
+ allied_deployment: sort_deployment_for_allied([...EGYPT, ...LIBYA]),
axis_initial_supply: 6,
allied_initial_supply: 6,
},
"Crusader": {
start: 8,
end: 10,
- axis_deployment: sort_deployment_for_axis(region_libya_and_sidi_omar_and_sollum_except_tobruk),
- allied_deployment: sort_deployment_for_allied(region_egypt_and_tobruk),
+ axis_deployment: sort_deployment_for_axis([...LIBYA_NO_TOBRUK, SIDI_OMAR, SOLLUM]),
+ allied_deployment: sort_deployment_for_allied([...EGYPT, TOBRUK]),
axis_initial_supply: 10,
allied_initial_supply: 12,
},
"Battleaxe": {
start: 4,
end: 10,
- axis_deployment: sort_deployment_for_axis(region_libya_except_tobruk),
- allied_deployment: sort_deployment_for_allied(region_egypt_and_tobruk),
+ axis_deployment: sort_deployment_for_axis(LIBYA_NO_TOBRUK),
+ allied_deployment: sort_deployment_for_allied([...EGYPT, TOBRUK]),
axis_initial_supply: 4,
allied_initial_supply: 8,
},
@@ -6506,7 +6499,7 @@ const SCENARIOS = {
start: 11,
end: 20,
axis_deployment: [ EL_AGHEILA, MERSA_BREGA ],
- allied_deployment: sort_deployment_for_allied(region_egypt_and_libya),
+ allied_deployment: sort_deployment_for_allied([...EGYPT, ...LIBYA]),
axis_initial_supply: 5,
allied_initial_supply: 5,
deployment_limit: {
@@ -6528,8 +6521,8 @@ const SCENARIOS = {
"Pursuit to Alamein": {
start: 15,
end: 20,
- axis_deployment: sort_deployment_for_axis(regions["Libya"]),
- allied_deployment: sort_deployment_for_allied(regions["Egypt"]),
+ axis_deployment: sort_deployment_for_axis(LIBYA),
+ allied_deployment: sort_deployment_for_allied(EGYPT),
axis_initial_supply: 8,
allied_initial_supply: 8,
},
@@ -6537,7 +6530,7 @@ const SCENARIOS = {
start: 1,
end: 20,
axis_deployment: [],
- allied_deployment: sort_deployment_for_allied(region_egypt_and_libya),
+ allied_deployment: sort_deployment_for_allied([...EGYPT, ...LIBYA]),
axis_initial_supply: 6,
allied_initial_supply: 6,
},