summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-11-27 22:13:50 +0100
committerTor Andersson <tor@ccxvii.net>2022-11-27 22:20:31 +0100
commita6a37f8a45368d195e0c4d497958f99430183223 (patch)
treedeca41ed8e512a71e21edf84059e36549082192b
parenta6444c0637b2ba63d6f22c66d8ed9dcdbb50b47b (diff)
downloadrommel-in-the-desert-a6a37f8a45368d195e0c4d497958f99430183223.tar.gz
Check validity of mandatory pass group moves.
-rw-r--r--rules.js16
1 files changed, 12 insertions, 4 deletions
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)