From a0c45f508147969b9f83070d973cf030e3af14ed Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 20 Aug 2024 14:31:48 +0200 Subject: dice images and colored rating numbers in log --- play.js | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 3 deletions(-) (limited to 'play.js') diff --git a/play.js b/play.js index 3b11b69..2a792f5 100644 --- a/play.js +++ b/play.js @@ -225,6 +225,12 @@ function build_piece(cn, w, h) { } function on_init() { + document.getElementById("war_ends").addEventListener("mouseenter", on_focus_war_ends) + document.getElementById("war_ends").addEventListener("mouseleave", on_blur_war_ends) + + document.getElementById("last_played").addEventListener("mouseenter", on_focus_last_played) + document.getElementById("last_played").addEventListener("mouseleave", on_blur_last_played) + for (let c = 0; c <= 110; ++c) { let e = ui.cards[c] = document.createElement("div") e.className = "card card_" + c @@ -792,6 +798,10 @@ function sub_general(_match, p1) { return `${n}` } +function sub_minus(match, p1) { + return "\u2212" + p1 +} + function sub_card(_match, p1) { let x = p1 | 0 let n = data.cards[x].title @@ -822,12 +832,67 @@ function on_blur_general_tip(s) { ui.generals[s].classList.remove("tip") } -function on_focus_card_tip(s) { - ui.last_played.className = "card shrink card_" + s +function on_focus_card_tip(c) { + document.getElementById("tooltip").className = "card card_" + c } function on_blur_card_tip() { - ui.last_played.className = "card shrink card_" + view.last_played + document.getElementById("tooltip").classList = "hide" +} + +function on_focus_last_played() { + if (view.last_played) + document.getElementById("tooltip").className = "card card_" + view.last_played +} + +function on_blur_last_played() { + document.getElementById("tooltip").classList = "hide" +} + +function on_focus_war_ends() { + if (view.war_ends) + document.getElementById("tooltip").className = "card card_" + view.war_ends +} + +function on_blur_war_ends() { + document.getElementById("tooltip").classList = "hide" +} + +const ICONS = { + D1: '', + D2: '', + D3: '', + D4: '', + D5: '', + D6: '', + A1: '1', + A2: '2', + A3: '3', + A4: '4', + A5: '5', + A6: '6', + AB1: '1', + AB2: '2', + AB3: '3', + AB4: '4', + AB5: '5', + AB6: '6', + BB1: '1', + BB2: '2', + BB3: '3', + BB4: '4', + BB5: '5', + BB6: '6', + FB1: '1', + FB2: '2', + FB3: '3', + FB4: '4', + FB5: '5', + FB6: '6', +} + +function sub_icon(match) { + return ICONS[match] || match } function on_log(text) { @@ -870,6 +935,14 @@ function on_log(text) { text = text.replace(//g, ">") + text = text.replace(/-(\d)/g, sub_minus) + + text = text.replace(/\b[D][1-6]\b/g, sub_icon) + text = text.replace(/\b[A][1-6]\b/g, sub_icon) + text = text.replace(/\bAB[1-6]\b/g, sub_icon) + text = text.replace(/\bBB[1-6]\b/g, sub_icon) + text = text.replace(/\bFB[1-6]\b/g, sub_icon) + text = text.replace(/C(\d+)/g, sub_card) text = text.replace(/S(\d+)/g, sub_space) text = text.replace(/G(\d+)/g, sub_general) -- cgit v1.2.3