diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-09-01 12:37:19 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 11:54:52 +0100 |
commit | 5e0c76f4fcc07f3d891ad7b2745a4b8eaaf85308 (patch) | |
tree | 6f66428d0b361980c8a6d539437906cf0d4e59f0 | |
parent | bd0d3720b726ca64b95216986cb0b7dc6db9959e (diff) | |
download | wilderness-war-5e0c76f4fcc07f3d891ad7b2745a4b8eaaf85308.tar.gz |
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.
-rw-r--r-- | rules.js | 31 |
1 files changed, 19 insertions, 12 deletions
@@ -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() } |