diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-12-15 00:16:39 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-01-08 16:36:48 +0100 |
commit | 89a3e6f8c8b6feb94f4cd7fe4694d75d523b4405 (patch) | |
tree | 057fbf2d5cbedde3a7a91ced99abc7405cdf01a7 /play.js | |
parent | 8d5c0d1f4675e63ccd48c62a853264d2723c2626 (diff) | |
download | table-battles-89a3e6f8c8b6feb94f4cd7fe4694d75d523b4405.tar.gz |
log icons
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 62 |
1 files changed, 62 insertions, 0 deletions
@@ -425,6 +425,68 @@ for (let i = 0; i < 12; ++i) { register_animation(ui.dice[i], 250) } +const ICONS = { + D0: '<span class="die black d0"></span>', + D1: '<span class="die black d1"></span>', + D2: '<span class="die black d2"></span>', + D3: '<span class="die black d3"></span>', + D4: '<span class="die black d4"></span>', + D5: '<span class="die black d5"></span>', + D6: '<span class="die black d6"></span>', + R1: '<span class="die red d1"></span>', + R2: '<span class="die red d2"></span>', + R3: '<span class="die red d3"></span>', + R4: '<span class="die red d4"></span>', + R5: '<span class="die red d5"></span>', + R6: '<span class="die red d6"></span>', + P1: '<span class="die pink d1"></span>', + P2: '<span class="die pink d2"></span>', + P3: '<span class="die pink d3"></span>', + P4: '<span class="die pink d4"></span>', + P5: '<span class="die pink d5"></span>', + P6: '<span class="die pink d6"></span>', + B1: '<span class="die blue d1"></span>', + B2: '<span class="die blue d2"></span>', + B3: '<span class="die blue d3"></span>', + B4: '<span class="die blue d4"></span>', + B5: '<span class="die blue d5"></span>', + B6: '<span class="die blue d6"></span>', + K1: '<span class="die dkblue d1"></span>', + K2: '<span class="die dkblue d2"></span>', + K3: '<span class="die dkblue d3"></span>', + K4: '<span class="die dkblue d4"></span>', + K5: '<span class="die dkblue d5"></span>', + K6: '<span class="die dkblue d6"></span>', +} + +function sub_icon(match) { + return ICONS[match] +} + +function sub_card(match) { + let wing = "" + let name = match + return `<span class="${wing}">${name}</span>` +} + +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 |