diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-09-30 20:38:16 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-17 13:11:27 +0100 |
commit | e2b4501b9655dae272187860ca6cbe478783e4de (patch) | |
tree | f6946337464fd0de48625a14a71b73e9db978708 | |
parent | a0b060839c320d6fa47fbe3b49c349a32aac8180 (diff) | |
download | rommel-in-the-desert-e2b4501b9655dae272187860ca6cbe478783e4de.tar.gz |
Don't allow "end turn" during pass moves if there are mandatory battles.
-rw-r--r-- | rules.js | 28 |
1 files changed, 18 insertions, 10 deletions
@@ -3001,10 +3001,14 @@ states.select_moves = { view.actions.regroup = can_regroup_move } - if (game.turn_option === 'pass') - gen_action('end_turn') - else if (!can_group_move && !can_regroup_move) + if (game.turn_option === 'pass') { + if (has_mandatory_combats() && (can_group_move || can_regroup_move)) + view.actions.end_turn = 0 + else + view.actions.end_turn = 1 + } else if (!can_group_move && !can_regroup_move) { gen_action('end_move') + } }, group_rommel() { push_undo() @@ -3293,7 +3297,7 @@ function can_end_move() { // must retreat from mandatory combat! for (let fortress of FORTRESS_HEX_LIST) { if (is_hex_or_adjacent_to(game.from1, fortress)) - if (is_mandatory_combat(fortress) && set_has(fortress, game.regroup.always)) + if (is_mandatory_combat(fortress) && set_has(game.regroup.always, fortress)) return !has_friendly_unit(fortress) } @@ -3397,6 +3401,7 @@ states.move = { break } } + if (has_overrun_hex) { if (can_move) view.prompt = `Movement: Select unit to move, or hex to overrun.` @@ -3413,13 +3418,12 @@ states.move = { if (can_end_move()) gen_action_end_move() } else { - if (can_end_move()) { - if (can_move) - view.prompt = `Movement: Select unit to move.` - else - view.prompt = `Movement: Done.` + if (can_move) + view.prompt = `Movement: Select unit to move.` + else + view.prompt = `Movement: Done.` + if (can_end_move()) gen_action_end_move() - } } } } else { @@ -4570,6 +4574,10 @@ function end_rout() { // ==== COMBAT PHASE === +function has_mandatory_combats() { + return is_mandatory_combat(BARDIA) || is_mandatory_combat(BENGHAZI) || is_mandatory_combat(TOBRUK) +} + function is_mandatory_combat(fortress) { if (is_battle_hex(fortress)) { if (game.phasing === AXIS) |