diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-11-01 20:28:51 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-11-01 20:28:51 +0100 |
commit | 065ac069ed8109ba67c10ea6874fd442ec0b4ab9 (patch) | |
tree | 78b7aa73a5a79af16ef925ac1c91ae787ffca9b5 | |
parent | c6203fe6c2b81e075671405b97bec8f6a93db515 (diff) | |
download | maria-065ac069ed8109ba67c10ea6874fd442ec0b4ab9.tar.gz |
fix victory pool display (missed elector majority)
-rw-r--r-- | play.js | 39 | ||||
-rw-r--r-- | rules.js | 20 |
2 files changed, 42 insertions, 17 deletions
@@ -1119,35 +1119,60 @@ function layout_retro(s, pow) { ui.markers_element.appendChild(e) } -function layout_victory_pool(pow, max, x, y) { +function elector_majority() { + let elector_france = 0 + let elector_pragmatic = 0 + for (let i = 0; i < 8; i += 2) { + if (view.elector[i+1] === P_FRANCE) + elector_france ++ + else + elector_pragmatic ++ + } + if (elector_france >= 3) + return P_FRANCE + if (elector_pragmatic >= 3) + return P_PRAGMATIC + return -1 +} + +function count_victory_markers(pow) { let n = view.vp[pow] - let m = 0 if (pow === P_PRUSSIA) { - m = view.vp[SET_ASIDE_PRUSSIA] - n += m + n += view.vp[SET_ASIDE_PRUSSIA] if (view.flags & F_SILESIA_ANNEXED) ++n } if (pow === P_FRANCE) { - m = view.vp[SET_ASIDE_FRANCE] - n += m + n += view.vp[SET_ASIDE_FRANCE] if (view.flags & F_ITALY_FRANCE) ++n if (view.flags & F_EMPEROR_FRANCE) ++n + if (elector_majority() === P_FRANCE) ++n } if (pow === P_AUSTRIA) { if (view.flags & F_ITALY_AUSTRIA) ++n if (view.flags & F_EMPEROR_AUSTRIA) ++n } + if (pow === P_PRAGMATIC) { + if (elector_majority() === P_PRAGMATIC) ++n + } for (let i = 0; i < view.victory.length; i += 2) if (view.victory[i+1] === pow) ++n + return n +} +function layout_victory_pool(pow, max, x, y) { + let n = count_victory_markers(pow) + let m = 0 + if (pow === P_PRUSSIA) + m = view.vp[SET_ASIDE_PRUSSIA] + if (pow === P_FRANCE) + m = view.vp[SET_ASIDE_FRANCE] for (let i = 0; i < max - n; ++i) { let e = ui.victory[pow][used_victory[pow]++] e.style.left = (x - 16 + (i%5) * 20) + "px" e.style.top = (y - 16 + (i/5|0) * 20) + "px" ui.markers_element.appendChild(e) } - for (let i = 0; i < m; ++i) { let e = ui.victory[pow][used_victory[pow]++] if (pow === P_FRANCE) { @@ -3116,7 +3116,7 @@ function goto_winter_turn() { // record winter scores for (let pow of all_major_powers) - game.score[pow].push(count_vp_markers_in_pool(pow)) + game.score[pow].push(count_victory_markers_in_pool(pow)) if (is_intro()) { if (game.turn === 10) { @@ -4107,7 +4107,7 @@ function elector_majority() { return -1 } -function count_vp_markers(pow) { +function count_victory_markers(pow) { let n = game.vp[pow] if (pow === P_PRUSSIA) { n += game.vp[SET_ASIDE_PRUSSIA] @@ -4132,8 +4132,8 @@ function count_vp_markers(pow) { return n } -function count_vp_markers_in_pool(pow) { - return Math.max(0, power_victory_target[pow] - count_vp_markers(pow)) +function count_victory_markers_in_pool(pow) { + return Math.max(0, power_victory_target[pow] - count_victory_markers(pow)) } function count_victory_markers_in_country(pow, country) { @@ -4174,10 +4174,10 @@ function check_instant_victory() { return check_instant_victory_intro() let margin = [ - count_vp_markers(P_FRANCE) - 11, - count_vp_markers(P_PRUSSIA) - 13, - count_vp_markers(P_PRAGMATIC) - 8, - count_vp_markers(P_AUSTRIA) - 8, + count_victory_markers(P_FRANCE) - 11, + count_victory_markers(P_PRUSSIA) - 13, + count_victory_markers(P_PRAGMATIC) - 8, + count_victory_markers(P_AUSTRIA) - 8, ] let best = 0 @@ -5419,7 +5419,7 @@ states.silesia_done = { function goto_france_reduces_military_objectives() { if ( !(game.flags & F_FRANCE_REDUCED) && - count_french_vp_markers_in_core_austria() > 0 && + count_french_victory_markers_in_core_austria() > 0 && france_has_no_generals_in_core_austria() ) game.state = "france_reduces_military_objectives" @@ -5427,7 +5427,7 @@ function goto_france_reduces_military_objectives() { next_sequence_of_play() } -function count_french_vp_markers_in_core_austria() { +function count_french_victory_markers_in_core_austria() { let n = 0 map_for_each(game.victory, (s, pow) => { if (pow === P_FRANCE && set_has(all_core_austria_cities, s)) |