From 89a3e6f8c8b6feb94f4cd7fe4694d75d523b4405 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 15 Dec 2023 00:16:39 +0100 Subject: log icons --- play.js | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'play.js') diff --git a/play.js b/play.js index 138fdc1..b8d9e00 100644 --- a/play.js +++ b/play.js @@ -425,6 +425,68 @@ for (let i = 0; i < 12; ++i) { register_animation(ui.dice[i], 250) } +const ICONS = { + D0: '', + D1: '', + D2: '', + D3: '', + D4: '', + D5: '', + D6: '', + R1: '', + R2: '', + R3: '', + R4: '', + R5: '', + R6: '', + P1: '', + P2: '', + P3: '', + P4: '', + P5: '', + P6: '', + B1: '', + B2: '', + B3: '', + B4: '', + B5: '', + B6: '', + K1: '', + K2: '', + K3: '', + K4: '', + K5: '', + K6: '', +} + +function sub_icon(match) { + return ICONS[match] +} + +function sub_card(match) { + let wing = "" + let name = match + return `${name}` +} + +function on_log(text) { + let p = document.createElement("div") + if (text.match(/^\.h1 /)) { + text = text.substring(4) + p.className = "h1" + } + else if (text.match(/^\.h2 /)) { + text = text.substring(4) + p.className = "h2" + } + + text = text.replace(/\bC\d+\b/g, sub_card) + text = text.replace(/\b[DPRBK]\d\b/g, sub_icon) + + p.innerHTML = text + return p +} + function set_has(set, item) { let a = 0 let b = set.length - 1 -- cgit v1.2.3