From a25b93cf1fd61c44c6608d97630b6c0e6b106372 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 12 Apr 2025 13:15:00 +0200 Subject: "Short" faction names in log. Brighter colors. --- play.js | 154 ++++++++++++++++++++++++++++------------------------------------ 1 file changed, 67 insertions(+), 87 deletions(-) (limited to 'play.js') diff --git a/play.js b/play.js index b57f663..3b28218 100644 --- a/play.js +++ b/play.js @@ -968,6 +968,7 @@ function is_stacked() { } function update_discard() { + // TODO when rewind and needs to empty if ("discard" in view) { let stacked = is_stacked() ui.discard_pile.style.flexDirection = (stacked ? "column" : "row") @@ -1376,24 +1377,41 @@ function sub_space(match, p1) { return `${n}` } -const D_DS = '' -const D_BK = '' -const D_VE = '' - -const E_DS = '' -const E_BK = '' -const E_VE = '' - -const C_DS = '' -const C_MI = '' - -const F_DS = '' -const F_BK = '' -const F_VE = '' -const F_MI = '' +const ICONS = { + DDS: '', + DBK: '', + DVE: '', + EDS: '', + EBK: '', + EVE: '', + CDS: '', + CMI: '', + + FDS: '', + FBK: '', + FVE: '', + FMI: '', + IBK: '', + IVE: '', + + A1: '\u2776', + A2: '\u2777', + A3: '\u2778', + A4: '\u2779', + A5: '\u277A', + A6: '\u277B', + + D1: '\u2460', + D2: '\u2461', + D3: '\u2462', + D4: '\u2463', + D5: '\u2464', + D6: '\u2465', +} -const I_BK = '' -const I_VE = '' +function sub_icon(match) { + return ICONS[match] ?? match +} function on_prompt(text) { return text.replaceAll("a Amir", "an Amir") @@ -1402,6 +1420,7 @@ function on_prompt(text) { function on_log(text) { let p = document.createElement("div") let sub_text = "" + let ix if (text.match(/^>/)) { text = text.substring(1) @@ -1414,98 +1433,59 @@ function on_log(text) { text = text.replace(//g, ">") - text = text.replace(/\bDDS\b/g, D_DS) - text = text.replace(/\bDBK\b/g, D_BK) - text = text.replace(/\bDVE\b/g, D_VE) - text = text.replace(/\bCDS\b/g, C_DS) - text = text.replace(/\bCMI\b/g, C_MI) - text = text.replace(/\bEDS\b/g, E_DS) - text = text.replace(/\bEBK\b/g, E_BK) - text = text.replace(/\bEVE\b/g, E_VE) - text = text.replace(/\bFDS\b/g, F_DS) - text = text.replace(/\bFBK\b/g, F_BK) - text = text.replace(/\bFVE\b/g, F_VE) - text = text.replace(/\bFMI\b/g, F_MI) - text = text.replace(/\bIBK\b/g, I_BK) - text = text.replace(/\bIVE\b/g, I_VE) - - if (text.match(/^\.h1 Mongol Invaders/)) { - text = text.substring(19) - p.className = "h1 mi" - } - else if (text.match(/^\.h1 succ/)) { - sub_text = text.substring(4, 9) - text = text.substring(10) - p.className = "h1 " + sub_text - } - else if (text.match(/^\.h1/)) { + text = text.replace(/\bDDS\b/g, sub_icon) + text = text.replace(/\bDBK\b/g, sub_icon) + text = text.replace(/\bDVE\b/g, sub_icon) + text = text.replace(/\bCDS\b/g, sub_icon) + text = text.replace(/\bCMI\b/g, sub_icon) + text = text.replace(/\bEDS\b/g, sub_icon) + text = text.replace(/\bEBK\b/g, sub_icon) + text = text.replace(/\bEVE\b/g, sub_icon) + text = text.replace(/\bFDS\b/g, sub_icon) + text = text.replace(/\bFBK\b/g, sub_icon) + text = text.replace(/\bFVE\b/g, sub_icon) + text = text.replace(/\bFMI\b/g, sub_icon) + text = text.replace(/\bIBK\b/g, sub_icon) + text = text.replace(/\bIVE\b/g, sub_icon) + + text = text.replace(/\b[AD][1-6]\b/g, sub_icon) + + text = text.replace(/ - /g, " \u2013 ") + + if (text.match(/^\.h1 C/)) { text = text.substring(4) - p.className = "h1" + ix = parseInt(text.substring(1)) + if (ix >= 37 && ix <= 44) p.className = "h1 mi" + else if (ix === 45) p.className = "h1 succ1" + else if (ix === 46) p.className = "h1 succ2" + else if (ix === 47) p.className = "h1 succ3" + else if (ix >= 48 && ix <= 49) p.className = "h1 mi" + else p.className = "h1" } - else if (text.match(/^\.h2 Delhi Sultanate/)) { + else if (text.match(/^\.h2 Sultanate/)) { text = text.substring(4) p.className = "h2 ds" } - else if (text.match(/^\.h2 DS/)) { - text = text.substring(6) - p.className = "h2 ds italic" - } - else if (text.match(/^\.h2 Bahmani Kingdom/)) { + else if (text.match(/^\.h2 Bahmani/)) { text = text.substring(4) p.className = "h2 bk" } - else if (text.match(/^\.h2 BK/)) { - text = text.substring(6) - p.className = "h2 bk italic" - } - else if (text.match(/^\.h2 Vijayanagara Empire/)) { + else if (text.match(/^\.h2 Vijayanagara/)) { text = text.substring(4) p.className = "h2 ve" } - else if (text.match(/^\.h2 VE/)) { - text = text.substring(6) - p.className = "h2 ve italic" - } - else if (text.match(/^\.h2 Mongol Invaders/)) { - text = text.substring(4) - p.className = "h2 mi" - } - else if (text.match(/^\.h2 MI/)) { + else if (text.match(/^\.h2 Mongol/)) { text = text.substring(4) p.className = "h2 mi" } - else if (text.match(/^\.h2 /)) { - text = text.substring(3) - p.className = "h2" - } else if (text.match(/^\.h3/)) { text = text.substring(4) p.className = "h3" } - else if (text.match(/^\.h4/)) { - text = text.substring(4) - p.className = "h4" - } - else if (text.match(/^\.n/)) { - text = text.substring(3) - p.className = "italic" - } else if (text.match(/^\.i/)) { - text = text.substring(3) - p.className = "indent italic" - } - else if (text.match(/^\.e/)) { text = text.substring(3) p.className = "italic" } - else if (text.match(/^\.ad/)) { - text = text.substring(4) - p.className += " adice" - } - else if (text.match(/^\.dd/)) { - text = text.substring(4) - p.className += " ddice" - } text = text.replace(/C(\d+)/g, sub_card) text = text.replace(/S(\d+)/g, sub_space) -- cgit v1.2.3