From 0c8cc28fc48a192d476c5b394256468735861289 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 16 Oct 2024 22:36:56 +0200 Subject: Log losses from mixed stacks. --- rules.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rules.js b/rules.js index 28415a6..718f593 100644 --- a/rules.js +++ b/rules.js @@ -2085,8 +2085,8 @@ function remove_stack_from_combat(s) { } function goto_retreat() { - let lost = Math.abs(game.count) - let hits = lost + let hits = Math.abs(game.count) + let lost = [ 0, 0, 0, 0, 0, 0 ] // per power! let loser = get_loser() let loser_power = get_stack_power(loser) @@ -2099,6 +2099,7 @@ function goto_retreat() { for (let i = game.selected.length - 1; i >= 0 && hits > 0; --i) { let p = game.selected[i] while (game.troops[p] > 1 && hits > 0) { + lost[piece_power[p]]++ --game.troops[p] --hits } @@ -2107,12 +2108,15 @@ function goto_retreat() { for (let i = game.selected.length - 1; i >= 0 && hits > 0; --i) { let p = game.selected[i] while (game.troops[p] > 0 && hits > 0) { + lost[piece_power[p]]++ --game.troops[p] --hits } } - log(POWER_NAME[loser_power] + " lost " + (lost-hits) + " troops.") + for (let pow of all_powers) + if (lost[pow] > 0) + log(POWER_NAME[pow] + " lost " + (lost[pow]) + " troops.") resume_retreat() } -- cgit v1.2.3