summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-06-23 18:07:18 +0200
committerTor Andersson <tor@ccxvii.net>2023-07-07 18:39:37 +0200
commit4251b1dedc84f8622355542be7d64a020f398a26 (patch)
tree0cdf550fe9d30191d8e0a0827489ab18798c2e22 /play.js
parent55578bb49831b1636e0a3ec6826d5a0844b953b0 (diff)
downloadtime-of-crisis-4251b1dedc84f8622355542be7d64a020f398a26.tar.gz
Start log formatting.
Diffstat (limited to 'play.js')
-rw-r--r--play.js76
1 files changed, 76 insertions, 0 deletions
diff --git a/play.js b/play.js
index 972754a..9c4eb7c 100644
--- a/play.js
+++ b/play.js
@@ -3,6 +3,23 @@
// TODO: battle dialog popup for rolling and assigning hits!
// TODO: show killed leaders taken for bonus purchase
+const DICE = {
+ B0: '<span class="black d0"></span>',
+ B1: '<span class="black d1"></span>',
+ B2: '<span class="black d2"></span>',
+ B3: '<span class="black d3"></span>',
+ B4: '<span class="black d4"></span>',
+ B5: '<span class="black d5"></span>',
+ B6: '<span class="black d6"></span>',
+ W0: '<span class="white d0"></span>',
+ W1: '<span class="white d1"></span>',
+ W2: '<span class="white d2"></span>',
+ W3: '<span class="white d3"></span>',
+ W4: '<span class="white d4"></span>',
+ W5: '<span class="white d5"></span>',
+ W6: '<span class="white d6"></span>',
+}
+
// === SYNC with rules.js ===
const LEGION_COUNT = 33
@@ -1304,5 +1321,64 @@ function on_update() {
action_button("undo", "Undo")
}
+function sub_region_name(match, p1) {
+ let x = p1 | 0
+ return REGION_NAME[x]
+}
+
+function sub_dice_image(match) {
+ return DICE[match]
+}
+
+function on_log(text) {
+ let p = document.createElement("div")
+
+ if (text.match(/^>/)) {
+ text = text.substring(1)
+ p.className = 'i'
+ }
+
+ text = text.replace(/&/g, "&amp;")
+ text = text.replace(/</g, "&lt;")
+ text = text.replace(/>/g, "&gt;")
+
+ text = text.replace(/S(\d+)/g, sub_region_name)
+ text = text.replace(/\b[BW]\d\b/g, sub_dice_image)
+
+ if (text.match(/^.turn/)) {
+ text = text.substring(6)
+ p.className = 'turn ' + text
+ }
+
+ if (text.match(/^\.h1/)) {
+ text = text.substring(4)
+ p.className = "h1"
+ }
+ else if (text.match(/^\.h2 Red/)) {
+ text = text.substring(4)
+ p.className = "h2 p_red"
+ }
+ else if (text.match(/^\.h2 Blue/)) {
+ text = text.substring(4)
+ p.className = "h2 p_blue"
+ }
+ else if (text.match(/^\.h2 Yellow/)) {
+ text = text.substring(4)
+ p.className = "h2 p_yellow"
+ }
+ else if (text.match(/^\.h2 Green/)) {
+ text = text.substring(4)
+ p.className = "h2 p_green"
+ }
+ if (text.match(/^\.h3/)) {
+ text = text.substring(4)
+ p.className = "h3"
+ }
+
+ p.innerHTML = text
+ return p
+}
+
+
on_init()
scroll_with_middle_mouse("main")