diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-11-25 12:40:44 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-11-25 12:40:48 +0100 |
commit | cfb1e5c492c621d6ca3880b903a66c8c754a9735 (patch) | |
tree | 60928f935e8ee0fb7cc5b0e8c85e0f0c12b3b6e4 /play.js | |
parent | a399cee53288ca1dac0b203132068418807caac2 (diff) | |
download | maria-cfb1e5c492c621d6ca3880b903a66c8c754a9735.tar.gz |
responsive political display
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -542,7 +542,8 @@ const ui = { markers_element: document.getElementById("markers"), pol_tracks: document.getElementById("pol_tracks"), pc_deck: document.getElementById("pc_deck"), - pc_show: document.getElementById("pc_show"), + pc_show_1: document.getElementById("pc_show_1"), + pc_show_2: document.getElementById("pc_show_2"), pc_placed: [ document.getElementById("placed_france"), document.getElementById("placed_prussia"), @@ -1339,6 +1340,11 @@ function update_player_power_list(role) { } } +function update_player_active(name) { + if (roles[name]) + roles[name].element.classList.toggle("active", player_from_power(view.power) === name) +} + function cmp_tc(a, b) { let ax = (to_suit(a) << 7) + (to_value(a) << 3) + to_deck(a) let bx = (to_suit(b) << 7) + (to_value(b) << 3) + to_deck(b) @@ -1405,10 +1411,13 @@ function update_political() { ui.pc_placed[pow].appendChild(show_tc(tc)) } - ui.pc_show.replaceChildren() + ui.pc_show_1.replaceChildren() + ui.pc_show_2.replaceChildren() if (view.political) { - for (let pc of view.political) - ui.pc_show.appendChild(ui.political[pc]) + if (view.political.length > 0) + ui.pc_show_1.appendChild(ui.political[view.political[0]]) + if (view.political.length > 1) + ui.pc_show_2.appendChild(ui.political[view.political[1]]) } } @@ -1423,10 +1432,15 @@ function on_update() { if (is_two_player()) { update_player_power_list(R_PLAYER_A) update_player_power_list(R_PLAYER_B) + update_player_active(R_PLAYER_A) + update_player_active(R_PLAYER_B) } else { update_player_power_list(R_MARIA_THERESA) update_player_power_list(R_FREDERICK) update_player_power_list(R_LOUIS_XV) + update_player_active(R_MARIA_THERESA) + update_player_active(R_FREDERICK) + update_player_active(R_LOUIS_XV) } used_victory.fill(0) |