summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'play.js')
-rw-r--r--play.js36
1 files changed, 35 insertions, 1 deletions
diff --git a/play.js b/play.js
index 0415fff..24f26ee 100644
--- a/play.js
+++ b/play.js
@@ -11,6 +11,8 @@ const ui = {
map_container: document.getElementById("pieces"),
+ tooltip: document.getElementById("tooltip"),
+
fascist_cards: document.getElementById("fascist_cards"),
trash: document.getElementById("trash"),
hand: document.getElementById("hand"),
@@ -586,6 +588,36 @@ function on_update() { // eslint-disable-line no-unused-vars
animation_register.forEach(animate_position)
}
+function on_focus_card_tip(x) {
+ ui.tooltip.className = "card card_" + x
+}
+
+function on_focus_medallion_tip(x) {
+ ui.tooltip.className = "pink token medallion medallion_" + x
+}
+
+function on_blur_tip(x) {
+ ui.tooltip.className = "hide"
+}
+
+function sub_card(_match, p1) {
+ return `<span class="tip" onmouseenter="on_focus_card_tip(${p1})" onmouseleave="on_blur_tip()">${data.cards[p1].title}</span>`
+}
+
+function sub_medallion(_match, p1) {
+ return `<span class="tip" onmouseenter="on_focus_medallion_tip(${p1})" onmouseleave="on_blur_tip()">${data.medallions[p1].name}</span>`
+}
+
+function sub_token(match) {
+ switch (match) {
+ case "Ta": return `<img src="images/icons/player_anarchist.png">`
+ case "Tc": return `<img src="images/icons/player_communist.png">`
+ case "Tm": return `<img src="images/icons/player_moderate.png">`
+ case "Tf": return `<img src="images/icons/player_fascist.png">`
+ }
+ return match
+}
+
function on_log(text) { // eslint-disable-line no-unused-vars
let p = document.createElement("div")
@@ -603,7 +635,9 @@ function on_log(text) { // eslint-disable-line no-unused-vars
text = text.replace(/>/g, "&gt;")
text = text.replace(/-( ?[\d(])/g, "\u2212$1")
- // text = text.replace(/C(\d+)/g, sub_card)
+ text = text.replace(/\bC(\d+)\b/g, sub_card)
+ text = text.replace(/\bM(\d+)\b/g, sub_medallion)
+ text = text.replace(/\bT[acmf]\b/g, sub_token)
if (text.startsWith("#")) {
p.className = "h " + text[1]