From a6a37f8a45368d195e0c4d497958f99430183223 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 27 Nov 2022 22:13:50 +0100 Subject: Check validity of mandatory pass group moves. --- rules.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 3c07ae1..08e38c0 100644 --- a/rules.js +++ b/rules.js @@ -3003,7 +3003,7 @@ states.select_moves = { } if (game.turn_option === 'pass') { - if (has_mandatory_combats() && (can_group_move || can_regroup_move)) + if (has_mandatory_withdrawals()) view.actions.end_turn = 0 else view.actions.end_turn = 1 @@ -3057,15 +3057,15 @@ function list_valid_group_moves() { function list_valid_withdrawal_group_moves() { let result = [] let mandatory = false - if (is_mandatory_combat(BARDIA)) { + if (is_mandatory_combat(BARDIA) && is_valid_withdrawal_group_move_from(BARDIA)) { set_add(result, BARDIA) mandatory = true } - if (is_mandatory_combat(BENGHAZI)) { + if (is_mandatory_combat(BENGHAZI) && is_valid_withdrawal_group_move_from(BENGHAZI)) { set_add(result, BENGHAZI) mandatory = true } - if (is_mandatory_combat(TOBRUK)) { + if (is_mandatory_combat(TOBRUK) && is_valid_withdrawal_group_move_from(TOBRUK)) { set_add(result, TOBRUK) mandatory = true } @@ -4582,6 +4582,14 @@ function has_mandatory_combats() { return is_mandatory_combat(BARDIA) || is_mandatory_combat(BENGHAZI) || is_mandatory_combat(TOBRUK) } +function has_mandatory_withdrawals() { + return ( + (is_mandatory_combat(BARDIA) && is_valid_withdrawal_group_move_from(BARDIA)) || + (is_mandatory_combat(BENGHAZI) && is_valid_withdrawal_group_move_from(BENGHAZI)) || + (is_mandatory_combat(TOBRUK) && is_valid_withdrawal_group_move_from(TOBRUK)) + ) +} + function is_mandatory_combat(fortress) { if (is_battle_hex(fortress)) { if (game.phasing === AXIS) -- cgit v1.2.3