summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.js32
1 files changed, 20 insertions, 12 deletions
diff --git a/play.js b/play.js
index f58fbe9..75a6fa2 100644
--- a/play.js
+++ b/play.js
@@ -1608,11 +1608,12 @@ function sub_card_x(match, p1, p2) {
return `<span class="tip ${match[0]}" onmouseenter="on_focus_influence_tip(${x})" onmouseleave="on_blur_tip()">${p1} ${p2}</span>`
}
-var log_combat = 0
+var log_combat2 = 0
+var log_combat1 = 0
var log_place = 0
var log_pretender = 0
-function on_log(text) {
+function on_log(text, ix) {
let p = document.createElement("div")
if (text.match(/^>/)) {
@@ -1667,14 +1668,20 @@ function on_log(text) {
p.className = "h3"
}
+ // Reset group box counters (when log is rewound)
+ if (ix <= log_combat2) log_combat2 = 0
+ if (ix <= log_combat1) log_combat1 = 0
+ if (ix <= log_place) log_place = 0
+ if (ix <= log_pretender) log_pretender = 0
+
// Group pretender messages
if (text.match(/^Pretender\.$/) || text.match(/^Occupied /)) {
- log_pretender = 1
+ log_pretender = ix
p.classList.add("h2")
text = text.replace(".", "")
}
- if (log_pretender === 1 && text === "")
+ if (log_pretender && text === "")
log_pretender = 0
if (log_pretender)
p.classList.add("group", "populace")
@@ -1683,9 +1690,10 @@ function on_log(text) {
if (text.match(/^Battle in /)) {
p.classList.add("h2")
- log_combat = 2
+ log_combat2 = ix
+ log_combat1 = ix
}
- if (log_combat > 0) {
+ if (log_combat1) {
if (
text === "DEFENDER" ||
text === "ATTACKER" ||
@@ -1695,21 +1703,21 @@ function on_log(text) {
)
p.classList.add("h3")
if (text === "RESULT")
- log_combat = 1
+ log_combat2 = 0
}
- if (log_combat === 1 && text === "")
- log_combat = 0
- if (log_combat)
+ if (log_combat1 && !log_combat2 && text === "")
+ log_combat1 = 0
+ if (log_combat1)
p.classList.add("group", "military")
// Group place governor
if (text.match(/^Place Governor in /) || text.match(/^Praetorian Guard in /)) {
- log_place = 1
+ log_place = ix
p.classList.add("h2")
text = text.replace(".", "")
}
- if (log_place === 1 && text === "")
+ if (log_place && text === "")
log_place = 0
if (log_place)
p.classList.add("group", "senate")