diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-05-21 15:58:36 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 12:31:29 +0100 |
commit | 6290483d7cc64275317e47af26eda84b7b11729c (patch) | |
tree | a3f2c4a8d4b40fa1327fedfc1b1d58829d621f22 /play.js | |
parent | 8862b6c209afa437d9670d9d25c77ce8fcffe118 (diff) | |
download | pax-pamir-6290483d7cc64275317e47af26eda84b7b11729c.tar.gz |
Tooltip on spaces and per-color highlights of cylinders.
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -36,14 +36,23 @@ const region_index = { "Punjab": Punjab, }; -const region_names = { +const space_names = { [Persia]: "Persia", [Transcaspia]: "Transcaspia", [Herat]: "Herat", [Kabul]: "Kabul", [Kandahar]: "Kandahar", [Punjab]: "Punjab", -}; + [Persia_Transcaspia]: "Persia/Transcaspia", + [Persia_Herat]: "Persia/Herat", + [Transcaspia_Herat]: "Transcaspia/Herat", + [Transcaspia_Kabul]: "Transcaspia/Kabul", + [Herat_Kabul]: "Herat/Kabul", + [Herat_Kandahar]: "Herat/Kandahar", + [Kabul_Kandahar]: "Kabul/Kandahar", + [Kabul_Punjab]: "Kabul/Punjab", + [Kandahar_Punjab]: "Kandahar/Punjab", +} cards.forEach(card => { if (card) { @@ -278,6 +287,10 @@ function on_focus_card(evt) { } } +function on_focus_space(evt) { + ui.status.textContent = space_names[evt.target.space]; +} + function on_click_space(evt) { send_action('space', evt.target.space); evt.stopPropagation(); @@ -653,7 +666,10 @@ function on_update() { else if (s <= 100) ui.spyrows[s].appendChild(ui.pieces[x]); else - ui.board.appendChild(ui.pieces[x]); + { + if (ui.pieces[x].parentElement !== ui.board) + ui.board.appendChild(ui.pieces[x]); + } ui.pieces[x].classList.toggle('action', is_piece_action(x)); ui.pieces[x].classList.toggle('selected', view.selected === x); ui.pieces[x].style = ""; @@ -662,9 +678,9 @@ function on_update() { for (let i = 0; i < 6; ++i) if (ruler[i] === -1) - ui.rule[i].classList = `rule ${region_names[i+Persia]} hide`; + ui.rule[i].classList = `rule ${space_names[i+Persia]} hide`; else - ui.rule[i].classList = `rule ${region_names[i+Persia]} ${player_names[ruler[i]]}`; + ui.rule[i].classList = `rule ${space_names[i+Persia]} ${player_names[ruler[i]]}`; ui.suit_political.classList.toggle('action', is_suit_action('Political')); ui.suit_intelligence.classList.toggle('action', is_suit_action('Intelligence')); @@ -746,6 +762,8 @@ function build_ui() { ui.spaces[i] = document.getElementById("svgmap").getElementById(n); ui.spaces[i].space = i; ui.spaces[i].addEventListener("click", on_click_space); + ui.spaces[i].addEventListener("mouseenter", on_focus_space); + ui.spaces[i].addEventListener("mouseleave", on_blur); } for (let c = 1; c < cards.length; ++c) { |