diff options
author | Tor Andersson <tor@ccxvii.net> | 2025-03-19 00:35:42 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2025-03-19 00:35:42 +0100 |
commit | 43751f0bdb0736cd2222fccc4c96af63369e4e4c (patch) | |
tree | 422c24f5228a87f6e1d42d778c513ce06a3e6dd7 /play.js | |
parent | aba8efc5d2d64725d79de4d284266e0f99b59605 (diff) | |
download | land-and-freedom-43751f0bdb0736cd2222fccc4c96af63369e4e4c.tar.gz |
Tweak log messages.
Loss result to "Fascist" (instead of "None").
Use correct faction in trash_card.
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -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, ">") 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] |