From 4251b1dedc84f8622355542be7d64a020f398a26 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 23 Jun 2023 18:07:18 +0200 Subject: Start log formatting. --- play.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'play.js') 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: '', + B1: '', + B2: '', + B3: '', + B4: '', + B5: '', + B6: '', + W0: '', + W1: '', + W2: '', + W3: '', + W4: '', + W5: '', + W6: '', +} + // === 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, "&") + text = text.replace(//g, ">") + + 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") -- cgit v1.2.3