summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-04-12 13:15:00 +0200
committerTor Andersson <tor@ccxvii.net>2025-04-12 14:36:31 +0200
commita25b93cf1fd61c44c6608d97630b6c0e6b106372 (patch)
tree8edf6d7db9cbb0375a2fc469d591ab38d73f6938 /play.js
parent6591f70043fe9ca16d34232d0ef35f8b89c179ec (diff)
downloadvijayanagara-a25b93cf1fd61c44c6608d97630b6c0e6b106372.tar.gz
"Short" faction names in log. Brighter colors.
Diffstat (limited to 'play.js')
-rw-r--r--play.js154
1 files changed, 67 insertions, 87 deletions
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 `<span class="tip" onmouseenter="on_focus_space_tip(${x})" onmouseleave="on_blur_space_tip(${x})" onmousedown="on_click_space_tip(${x})">${n}</span>`
}
-const D_DS = '<img class="d" src="pieces/ds_disk.svg">'
-const D_BK = '<img class="d" src="pieces/bk_disk.svg">'
-const D_VE = '<img class="d" src="pieces/ve_disk.svg">'
-
-const E_DS = '<img class="h" src="pieces/ds_governor.svg">'
-const E_BK = '<img class="h" src="pieces/bk_amir.svg">'
-const E_VE = '<img class="h" src="pieces/ve_raja.svg">'
-
-const C_DS = '<img class="c" src="pieces/ds_troop.svg">'
-const C_MI = '<img class="c" src="pieces/mongol_invader.svg">'
-
-const F_DS = '<img class="f" src="images/Flags_DS.png">'
-const F_BK = '<img class="f" src="images/Flags_BK.png">'
-const F_VE = '<img class="f" src="images/Flags_VE.png">'
-const F_MI = '<img class="f" src="images/Flags_MI.png">'
+const ICONS = {
+ DDS: '<img class="d" src="pieces/ds_disk.svg">',
+ DBK: '<img class="d" src="pieces/bk_disk.svg">',
+ DVE: '<img class="d" src="pieces/ve_disk.svg">',
+ EDS: '<img class="h" src="pieces/ds_governor.svg">',
+ EBK: '<img class="h" src="pieces/bk_amir.svg">',
+ EVE: '<img class="h" src="pieces/ve_raja.svg">',
+ CDS: '<img class="c" src="pieces/ds_troop.svg">',
+ CMI: '<img class="c" src="pieces/mongol_invader.svg">',
+
+ FDS: '<img class="f" src="images/Flags_DS.png">',
+ FBK: '<img class="f" src="images/Flags_BK.png">',
+ FVE: '<img class="f" src="images/Flags_VE.png">',
+ FMI: '<img class="f" src="images/Flags_MI.png">',
+ IBK: '<img class="i" src="images/Influence_BK.png">',
+ IVE: '<img class="i" src="images/Influence_VE.png">',
+
+ A1: '<span class="adice">\u2776</span>',
+ A2: '<span class="adice">\u2777</span>',
+ A3: '<span class="adice">\u2778</span>',
+ A4: '<span class="adice">\u2779</span>',
+ A5: '<span class="adice">\u277A</span>',
+ A6: '<span class="adice">\u277B</span>',
+
+ D1: '<span class="ddice">\u2460</span>',
+ D2: '<span class="ddice">\u2461</span>',
+ D3: '<span class="ddice">\u2462</span>',
+ D4: '<span class="ddice">\u2463</span>',
+ D5: '<span class="ddice">\u2464</span>',
+ D6: '<span class="ddice">\u2465</span>',
+}
-const I_BK = '<img class="i" src="images/Influence_BK.png">'
-const I_VE = '<img class="i" src="images/Influence_VE.png">'
+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, "&lt;")
text = text.replace(/>/g, "&gt;")
- 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)