From 5e0c76f4fcc07f3d891ad7b2745a4b8eaaf85308 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 1 Sep 2022 12:37:19 +0200 Subject: Fix case where retreating lone leader step was missed. Move the lone leader leader retreat check from end_move_step into the beginning of resume_move. This way, interrupting the end_move_step for "Massacre!" won't skip the leader retreats. --- rules.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/rules.js b/rules.js index efe3408..ce96410 100644 --- a/rules.js +++ b/rules.js @@ -2922,6 +2922,25 @@ function max_movement_cost(type) { } function resume_move() { + let who = moving_piece() + let where = moving_piece_space() + + let enemy_units = has_unbesieged_enemy_units(where) + let enemy_leader = has_unbesieged_enemy_leader(where) + let friendly_units = has_unbesieged_friendly_units(where) + let friendly_leader = has_unbesieged_friendly_leader(where) + + if (enemy_leader && !enemy_units && friendly_units) { + return goto_retreat_lone_leader(where, 'move') + } + + // Can happen if enemy intercepted into moving piece and lone friendly leaders remain after battle. + if (friendly_leader && !friendly_units && enemy_units) { + game.state = 'retreat_lone_leader' + game.retreat = { from: where, reason: 'friendly_move' } + return + } + // Interrupt for Foul Weather response at first opportunity to move. if (game.move.used < 0) { if (is_enemy_card_available(FOUL_WEATHER) && !enemy_player.pass_fw) { @@ -3640,18 +3659,6 @@ function end_move_step(final=false, overrun=false) { logbr() } - if (!is_lone_leader(who) && is_piece_on_map(who) - && has_unbesieged_enemy_leader(where) - && !has_unbesieged_enemy_units(where)) - return goto_retreat_lone_leader(where, 'move') - - // If enemy intercepted into moving piece and lone friendly leaders remain after battle. - if (has_unbesieged_friendly_leader(where) && !has_unbesieged_friendly_units(where) && has_unbesieged_enemy_units(where)) { - game.state = 'retreat_lone_leader' - game.retreat = { from: where, reason: 'friendly_move' } - return - } - resume_move() } -- cgit v1.2.3