summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js64
1 files changed, 25 insertions, 39 deletions
diff --git a/rules.js b/rules.js
index 2811b83..d476ba6 100644
--- a/rules.js
+++ b/rules.js
@@ -6244,10 +6244,11 @@ function end_game() {
// === DEPLOYMENT ===
function goto_free_deployment() {
+ log_h2(`${game.active} Deployment`)
game.state = 'free_deployment'
- game.selected = []
if (!has_friendly_unit_in_raw_hex(DEPLOY))
- end_free_deployment()
+ goto_initial_supply_cards()
+ game.selected = []
game.summary = {}
}
@@ -6321,37 +6322,18 @@ states.free_deployment = {
let keys = Object.keys(game.summary).sort((a,b)=>a-b)
for (let x of keys)
log(`>${game.summary[x]} at #${x}`)
-
- end_free_deployment()
- }
-}
-
-function end_free_deployment() {
- set_enemy_player()
- if (has_friendly_unit_in_raw_hex(DEPLOY)) {
- game.selected = []
- game.summary = {}
- log_h2("Allied Deployment")
- } else {
- game.selected = -1
game.summary = null
+
goto_initial_supply_cards()
}
}
function goto_initial_supply_cards() {
- game.phasing = AXIS
- set_active_player()
-
- set_clear(game.fired)
-
- log_h2("Initial Supply Cards")
-
- let scenario = current_scenario()
- deal_axis_supply_cards(scenario.axis_initial_supply)
- deal_allied_supply_cards(scenario.allied_initial_supply)
-
game.state = 'initial_supply_cards'
+ if (is_axis_player())
+ deal_axis_supply_cards(current_scenario().axis_initial_supply)
+ else
+ deal_allied_supply_cards(current_scenario().allied_initial_supply)
}
states.initial_supply_cards = {
@@ -6363,29 +6345,34 @@ states.initial_supply_cards = {
},
discard() {
if (is_axis_player()) {
- let n = game.axis_hand[REAL] + game.axis_hand[DUMMY]
- log(`Axis discarded ${n} cards.`)
+ log(`Axis discarded all cards.`)
game.axis_hand[REAL] = 0
game.axis_hand[DUMMY] = 0
- deal_axis_supply_cards(n)
- set_enemy_player()
+ deal_axis_supply_cards(current_scenario().axis_initial_supply)
} else {
- let n = game.allied_hand[REAL] + game.allied_hand[DUMMY]
- log(`Allied discarded ${n} cards.`)
+ log(`Allied discarded all cards.`)
game.allied_hand[REAL] = 0
game.allied_hand[DUMMY] = 0
- deal_allied_supply_cards(n)
- begin_game()
+ deal_allied_supply_cards(current_scenario().allied_initial_supply)
}
+ end_free_deployment()
},
keep() {
- if (is_axis_player())
- set_enemy_player()
- else
- begin_game()
+ end_free_deployment()
},
}
+function end_free_deployment() {
+ set_enemy_player()
+ if (has_friendly_unit_in_raw_hex(DEPLOY)) {
+ goto_free_deployment()
+ } else {
+ game.selected = -1
+ game.summary = null
+ begin_game()
+ }
+}
+
function begin_game() {
log_h1(current_month_name())
@@ -6840,7 +6827,6 @@ function setup(scenario_name) {
setup_fortress(scenario, BENGHAZI)
setup_fortress(scenario, TOBRUK)
- log_h2("Axis Deployment")
game.phasing = AXIS
set_active_player()