summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'play.js')
-rw-r--r--play.js68
1 files changed, 49 insertions, 19 deletions
diff --git a/play.js b/play.js
index 0214247..5aac58c 100644
--- a/play.js
+++ b/play.js
@@ -76,19 +76,48 @@ const step_up_animation = [
]
let ui = {
- cards: {},
- card_backs: {},
- spaces: {},
- blocks: {},
- battle_menu: {},
- battle_block: {},
+ cards: [],
+ card_backs: [],
+ spaces: [],
+ blocks: [],
+ battle_menu: [],
+ battle_block: [],
old_steps: null,
old_location: null,
present: new Set(),
}
+function on_focus_space_tip(x) {
+ ui.spaces[x].classList.add("tip")
+}
+
+function on_blur_space_tip(x) {
+ ui.spaces[x].classList.remove("tip")
+}
+
+function on_click_space_tip(x) {
+ ui.spaces[x].scrollIntoView({ block:"center", inline:"center", behavior:"smooth" })
+}
+
+function sub_space_name(match, p1, offset, string) {
+ let x = p1 | 0
+ let n = SPACES[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")
+
+ if (text.match(/^>>/)) {
+ text = text.substring(2)
+ p.className = "ii"
+ }
+
+ 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;")
@@ -98,19 +127,20 @@ function on_log(text) {
text = text.replace(/^([A-Z]):/, '<span class="$1"> $1 </span>')
- if (text.match(/^~ .* ~$/))
- p.className = 'br', text = text.substring(2, text.length-2)
- else if (text.match(/^Start Caesar/))
- p.className = 'C'
- else if (text.match(/^Start Pompeius/))
- p.className = 'P'
- else if (text.match(/^Start /))
- p.className = 'st', text = text.replace(/\.$/, "")
- else if (text.match(/^Battle in/))
- p.className = 'bs'
-
- if (text.match(/^Start /))
- text = text.substring(6)
+ text = text.replace(/#(\d+)/g, sub_space_name)
+
+ if (text.match(/^\.h1 /))
+ p.className = 'h1', text = text.substring(4)
+ if (text.match(/^\.h2 /))
+ p.className = 'h2', text = text.substring(4)
+ if (text.match(/^\.h3 C/))
+ p.className = 'h3 C', text = text.substring(4)
+ if (text.match(/^\.h3 P/))
+ p.className = 'h3 P', text = text.substring(4)
+ if (text.match(/^\.h4 /))
+ p.className = 'h4', text = text.substring(4)
+ if (text.match(/^\.h5 /))
+ p.className = 'h5', text = text.substring(4)
p.innerHTML = text
return p