From a883830f6370f0e7c27132641d69d6b8d5904a0f Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 25 Jul 2023 12:06:15 +0200 Subject: Fix tied emperor turns legacy calculation. --- rules.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rules.js b/rules.js index d7d6968..76acbaa 100644 --- a/rules.js +++ b/rules.js @@ -5249,17 +5249,18 @@ function max_emperor_turns(cutoff) { return n } -function award_emperor_turns(amount, cutoff) { +function award_emperor_turns(amount, n, cutoff) { let x = max_emperor_turns(cutoff) if (x > 0) { for (let p = 0; p < get_player_count(); ++p) { if (game.emperor_turns[p] === x) { logi(PLAYER_NAME[p] + " +" + amount + " Legacy") game.legacy[p] += amount + n += 1 } } } - return x + return [n, x] } function vp_tie(p) { @@ -5288,10 +5289,10 @@ function goto_game_end() { log_h3("Emperor Turns:") - let cutoff = award_emperor_turns(10, 1000) - cutoff = award_emperor_turns(6, cutoff) - cutoff = award_emperor_turns(3, cutoff) - award_emperor_turns(0, cutoff) + let [n, cutoff] = award_emperor_turns(10, 0, 1000) + if (n < 2) [n, cutoff] = award_emperor_turns(6, n, cutoff) + if (n < 3) [n, cutoff] = award_emperor_turns(3, n, cutoff) + award_emperor_turns(0, n, cutoff) log_h3("Final Score:") game.current = game.first -- cgit v1.2.3