From edcbe8f4ed27559a768270d71198626ed98f14a9 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 14 Nov 2024 23:27:17 +0100 Subject: Log mixed stack troop counts specially. --- rules.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index c51cdca..32e72b9 100644 --- a/rules.js +++ b/rules.js @@ -1249,6 +1249,19 @@ function get_supreme_commander(s) { return -1 } +function is_mixed_stack(s) { + let pow = -1 + for (let p of all_generals) { + if (game.pos[p] === s) { + if (pow < 0) + pow = piece_power[p] + else if (piece_power[p] !== pow) + return true + } + } + return false +} + function get_stack_power(s) { return piece_power[get_supreme_commander(s)] } @@ -3763,11 +3776,20 @@ function goto_resolve_combat() { game.count = a_troops - d_troops let a = get_supreme_commander(game.attacker) + let a_top = game.troops[a] let d = get_supreme_commander(game.defender) + let d_top = game.troops[d] log("!") log(`>P${a} at S${game.attacker}`) log(`>P${d} at S${game.defender}`) - log(`>Troops ${a_troops} - ${d_troops} = ${game.count}`) + if (is_mixed_stack(game.attacker) && is_mixed_stack(game.defender)) + log(`>Troops (${a_top}+${a_troops-a_top}) - (${d_top}+${d_troops-d_top}) = ${game.count}`) + else if (is_mixed_stack(game.attacker)) + log(`>Troops (${a_top}+${a_troops-a_top}) - ${d_troops} = ${game.count}`) + else if (is_mixed_stack(game.defender)) + log(`>Troops ${a_troops} - (${d_top}+${d_troops-d_top}) = ${game.count}`) + else + log(`>Troops ${a_troops} - ${d_troops} = ${game.count}`) if (game.count <= 0) { set_active_attacker() -- cgit v1.2.3