summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-05-26 00:05:43 +0200
committerTor Andersson <tor@ccxvii.net>2024-05-30 21:59:25 +0200
commitc1ade0f7b543591989ffb90a54d147de155e3d0a (patch)
tree259244c8da3918eb111530f800a4e35c59fe895a /play.js
parent97523a133617a632c9d688b2813388e9ac2a13f9 (diff)
downloadfriedrich-c1ade0f7b543591989ffb90a54d147de155e3d0a.tar.gz
colorize cards in prompt (need better colors)
Diffstat (limited to 'play.js')
-rw-r--r--play.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/play.js b/play.js
index 561fb0f..46e0083 100644
--- a/play.js
+++ b/play.js
@@ -265,6 +265,7 @@ function sort_power_panel() {
/* BUILD UI */
const ui = {
+ prompt: document.getElementById("prompt"),
header: document.querySelector("header"),
roads_element: document.getElementById("roads"),
spaces_element: document.getElementById("spaces"),
@@ -835,7 +836,24 @@ function cmp_tc(a, b) {
return ax - bx
}
+const colorize_S = '<span class="spades">$&</span>'
+const colorize_C = '<span class="clubs">$&</span>'
+const colorize_H = '<span class="hearts">$&</span>'
+const colorize_D = '<span class="diamonds">$&</span>'
+const colorize_R = '<span class="reserve">$&</span>'
+
+function colorize(text) {
+ text = text.replace(/\d+\u2660/g, colorize_S)
+ text = text.replace(/\d+\u2663/g, colorize_C)
+ text = text.replace(/\d+\u2665/g, colorize_H)
+ text = text.replace(/\d+\u2666/g, colorize_D)
+ text = text.replace(/\d+R/g, colorize_R)
+ return text
+}
+
function on_update() {
+ ui.prompt.innerHTML = colorize(view.prompt)
+
ui.header.classList.toggle("prussia", view.power === P_PRUSSIA)
ui.header.classList.toggle("hanover", view.power === P_HANOVER)
ui.header.classList.toggle("russia", view.power === P_RUSSIA)