diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-05-25 11:36:02 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-05-30 21:59:25 +0200 |
commit | 09b59209417144e30ed377b99dd3d9a63a004f93 (patch) | |
tree | 6cdf4337d68bd73c8e3ddf9be3b02e220be359fb | |
parent | dbdbfe86a88e9970e94c540cc487da11c763a310 (diff) | |
download | friedrich-09b59209417144e30ed377b99dd3d9a63a004f93.tar.gz |
sort card panels to always show current power on top
-rw-r--r-- | play.js | 60 |
1 files changed, 19 insertions, 41 deletions
@@ -233,6 +233,21 @@ const fate_effect_text = [ null, ] +/* PANEL ORDER */ + +const panel_order = [ P_PRUSSIA, P_HANOVER, P_RUSSIA, P_SWEDEN, P_AUSTRIA, P_IMPERIAL, P_FRANCE ] + +function sort_power_panel() { + let start = 0 + if (view) + start = view.power + ui.power_panel_list.replaceChildren() + for (let i = 0; i < 7; ++i) { + let p = panel_order[(i + start) % 7] + ui.power_panel_list.appendChild(ui.power_panel[p]) + } +} + /* BUILD UI */ const ui = { @@ -532,46 +547,7 @@ function on_init() { ui.spaces_element.appendChild(e) } - ui.power_panel_list.replaceChildren() - switch (params.role) { - default: - case "Friedrich": - ui.power_panel_list.appendChild(ui.power_panel[P_PRUSSIA]) - ui.power_panel_list.appendChild(ui.power_panel[P_HANOVER]) - ui.power_panel_list.appendChild(ui.power_panel[P_RUSSIA]) - ui.power_panel_list.appendChild(ui.power_panel[P_SWEDEN]) - ui.power_panel_list.appendChild(ui.power_panel[P_AUSTRIA]) - ui.power_panel_list.appendChild(ui.power_panel[P_IMPERIAL]) - ui.power_panel_list.appendChild(ui.power_panel[P_FRANCE]) - break - case "Elisabeth": - ui.power_panel_list.appendChild(ui.power_panel[P_RUSSIA]) - ui.power_panel_list.appendChild(ui.power_panel[P_SWEDEN]) - ui.power_panel_list.appendChild(ui.power_panel[P_AUSTRIA]) - ui.power_panel_list.appendChild(ui.power_panel[P_IMPERIAL]) - ui.power_panel_list.appendChild(ui.power_panel[P_FRANCE]) - ui.power_panel_list.appendChild(ui.power_panel[P_PRUSSIA]) - ui.power_panel_list.appendChild(ui.power_panel[P_HANOVER]) - break - case "Maria Theresa": - ui.power_panel_list.appendChild(ui.power_panel[P_AUSTRIA]) - ui.power_panel_list.appendChild(ui.power_panel[P_IMPERIAL]) - ui.power_panel_list.appendChild(ui.power_panel[P_FRANCE]) - ui.power_panel_list.appendChild(ui.power_panel[P_PRUSSIA]) - ui.power_panel_list.appendChild(ui.power_panel[P_HANOVER]) - ui.power_panel_list.appendChild(ui.power_panel[P_RUSSIA]) - ui.power_panel_list.appendChild(ui.power_panel[P_SWEDEN]) - break - case "Pompadour": - ui.power_panel_list.appendChild(ui.power_panel[P_FRANCE]) - ui.power_panel_list.appendChild(ui.power_panel[P_PRUSSIA]) - ui.power_panel_list.appendChild(ui.power_panel[P_HANOVER]) - ui.power_panel_list.appendChild(ui.power_panel[P_RUSSIA]) - ui.power_panel_list.appendChild(ui.power_panel[P_SWEDEN]) - ui.power_panel_list.appendChild(ui.power_panel[P_AUSTRIA]) - ui.power_panel_list.appendChild(ui.power_panel[P_IMPERIAL]) - break - } + sort_power_panel() update_favicon() } @@ -853,6 +829,8 @@ function on_update() { ui.header.classList.toggle("imperial", view.power === P_IMPERIAL) ui.header.classList.toggle("france", view.power === P_FRANCE) + sort_power_panel() + for (let g = 0; g <= 23; ++g) layout_general(g, view.pos[g]) for (let t = 24; t <= 34; ++t) @@ -922,7 +900,7 @@ function on_update() { action_button("end_turn", "End turn") action_button("undo", "Undo") - + process_actions() } |