diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-11-14 23:27:17 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-11-14 23:27:17 +0100 |
commit | edcbe8f4ed27559a768270d71198626ed98f14a9 (patch) | |
tree | 4667a0bb31c39c1773ba4f9507360df30ea8ba24 /rules.js | |
parent | ad88bc773de23e27f42690190b3d2ef277c816b1 (diff) | |
download | maria-edcbe8f4ed27559a768270d71198626ed98f14a9.tar.gz |
Log mixed stack troop counts specially.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -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() |