summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-10-02 22:55:13 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:12:55 +0100
commit048c9064a827b55bce6dda74e2007d616a33964d (patch)
treebae4e3666189f5a53ba9957ea7d9eccb80b27988 /play.js
parente269954c8a936600f3d3d7fdba156b046e586df5 (diff)
downloadrichard-iii-048c9064a827b55bce6dda74e2007d616a33964d.tar.gz
New log format.
Diffstat (limited to 'play.js')
-rw-r--r--play.js75
1 files changed, 46 insertions, 29 deletions
diff --git a/play.js b/play.js
index ea429df..ccac1cb 100644
--- a/play.js
+++ b/play.js
@@ -62,38 +62,55 @@ let ui = {
present: new Set(),
}
+function on_focus_space_tip(x) {
+ ui.areas[x].classList.add("tip")
+}
+
+function on_blur_space_tip(x) {
+ ui.areas[x].classList.remove("tip")
+}
+
+function on_click_space_tip(x) {
+ ui.areas[x].scrollIntoView({ block:"center", inline:"center", behavior:"smooth" })
+}
+
+function sub_space_name(match, p1, offset, string) {
+ let x = p1 | 0
+ let n = AREAS[x].name
+ return `<span class="tip" onmouseenter="on_focus_space_tip(${x})" onmouseleave="on_blur_space_tip(${x})" onclick="on_click_space_tip(${x})">${n}</span>`
+}
+
function on_log(text) {
- let p = document.createElement("div");
- text = text.replace(/&/g, "&amp;");
- text = text.replace(/</g, "&lt;");
- text = text.replace(/>/g, "&gt;");
-
- text = text.replace(/\u2192 /g, "\u2192\xa0");
-
- text = text.replace(/^([A-Z]):/, '<span class="$1"> $1 </span>');
-
- if (text.match(/^Scenario: /)) {
- p.className = 'st', text = text.substring(10);
- } else if (text.match(/^~ .* ~$/)) {
- p.className = 'br', text = text.substring(2, text.length-2);
- } else if (text.match(/^Start Lancaster turn/)) {
- text = "Lancaster";
- p.className = 'L';
- } else if (text.match(/^Start York turn/)) {
- text = "York";
- p.className = 'Y';
- } else if (text.match(/^Start /)) {
- p.className = 'st', text = text.replace(/\.$/, "");
- } else if (text.match(/^Battle in/)) {
- text = text.substring(0,text.length-1);
- p.className = 'bs';
- }
+ 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(/\u2192 /g, "\u2192\xa0")
+
+ text = text.replace(/^([A-Z]):/, '<span class="$1"> $1 </span>')
+
+ text = text.replace(/#(\d+)/g, sub_space_name)
- if (text.match(/^Start /))
- text = text.substring(6);
+ if (text.match(/^\.h1 /))
+ p.className = 'h1', text = text.substring(4)
+ if (text.match(/^\.h2 L/))
+ p.className = 'h2 L', text = text.substring(4)
+ if (text.match(/^\.h2 Y/))
+ p.className = 'h2 Y', text = text.substring(4)
+ if (text.match(/^\.h3 /))
+ p.className = 'h3', text = text.substring(4)
+ if (text.match(/^\.h4 /))
+ p.className = 'h4', text = text.substring(4)
- p.innerHTML = text;
- return p;
+ p.innerHTML = text
+ return p
}
function is_known_block(b) {