From a2d1bfbbd8ffdab0497455fa6d5cb364877a55ad Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 5 May 2024 12:03:11 +0200 Subject: skip hit assignment if zero hits or no targets --- rules.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'rules.ts') diff --git a/rules.ts b/rules.ts index 9f880e0..24d11a2 100644 --- a/rules.ts +++ b/rules.ts @@ -7502,9 +7502,22 @@ states.final_charge = { // === 4.4.2 BATTLE ROUNDS: ROLL BY HIT (PROTECTION ROLL, VALOUR RE-ROLL, FORCES ROUT) === +function no_remaining_targets() { + for (let pos of game.battle.engagements[0]) { + let lord = game.battle.array[pos] + if (is_friendly_lord(lord)) + if (lord_has_unrouted_units(lord)) + return false + } + return true +} + function goto_defender_assign_hits() { set_active_defender() - goto_assign_hits() + if (game.battle.ahits === 0 || no_remaining_targets()) + end_defender_assign_hits() + else + game.state = "assign_hits" } function end_defender_assign_hits() { @@ -7514,7 +7527,10 @@ function end_defender_assign_hits() { function goto_attacker_assign_hits() { set_active_attacker() - goto_assign_hits() + if (game.battle.dhits === 0 || no_remaining_targets()) + end_attacker_assign_hits() + else + game.state = "assign_hits" } function end_attacker_assign_hits() { @@ -7522,10 +7538,6 @@ function end_attacker_assign_hits() { end_battle_strike_step() } -function goto_assign_hits() { - game.state = "assign_hits" -} - function prompt_hit_forces() { let done = true for (let pos of game.battle.engagements[0]) { -- cgit v1.2.3