summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-10-06 11:29:11 +0200
committerTor Andersson <tor@ccxvii.net>2023-10-08 12:52:02 +0200
commit111988c6d409029a1a27e20ebb9a4e2c90bcfeab (patch)
treee0c9c98a9e8fe949bc44447df104d5afce1636e1
parent4a8d29b681c033596ef115583d0f6c5000f64f10 (diff)
downloadtime-of-crisis-111988c6d409029a1a27e20ebb9a4e2c90bcfeab.tar.gz
Put place governor actions and battles in colored boxes in log.
-rw-r--r--play.css12
-rw-r--r--play.js73
-rw-r--r--rules.js9
3 files changed, 75 insertions, 19 deletions
diff --git a/play.css b/play.css
index 94531b9..bdca4c8 100644
--- a/play.css
+++ b/play.css
@@ -38,11 +38,19 @@ body.Green .your_turn { background-color: hsl(99,36%,65%) }
#log { background-color: whitesmoke; }
#log .h1 { background-color: silver; font-weight: bold; padding-top:2px; padding-bottom:2px; margin: 8px 0; text-align: center; }
#log .h1 { border-bottom: 1px solid #444; border-top: 1px solid #444; }
-#log .h2 { background-color: gainsboro; text-align: center; }
-#log .h3 { text-decoration: underline; }
#log div { padding-left: 20px; text-indent: -12px; }
#log div.i { padding-left: 32px; text-indent: -12px; }
+#log .group { margin: 0 8px }
+
+#log .h2.group.military { background-color: hsl(358,20%,80%) }
+#log .h3.group.military { background-color: hsl(358,20%,85%) }
+#log .group.military { background-color: hsl(358,20%,90%) }
+#log .h2.group.senate { background-color: hsl(206,30%,85%) }
+#log .group.senate { background-color: hsl(206,30%,90%) }
+#log .h2.group.populace { background-color: hsl(44,40%,82%) }
+#log .group.populace { background-color: hsl(44,40%,87%) }
+
#log .white, #log .black {
display: inline-block;
vertical-align: -2px;
diff --git a/play.js b/play.js
index befa0f3..2beae4e 100644
--- a/play.js
+++ b/play.js
@@ -1586,12 +1586,16 @@ 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_place = 0
+var log_pretender = 0
+
function on_log(text) {
let p = document.createElement("div")
if (text.match(/^>/)) {
text = text.substring(1)
- p.className = 'i'
+ p.className = "i"
}
text = text.replace(/&/g, "&amp;")
@@ -1615,38 +1619,79 @@ function on_log(text) {
if (text.match(/^.turn/)) {
text = text.substring(6)
- p.className = 'turn ' + text
+ p.className = "turn " + text
}
if (text.match(/^\.h1 Red/)) {
text = text.substring(4)
p.className = "h1 R"
- }
- else if (text.match(/^\.h1 Blue/)) {
+ } else if (text.match(/^\.h1 Blue/)) {
text = text.substring(4)
p.className = "h1 B"
- }
- else if (text.match(/^\.h1 Yellow/)) {
+ } else if (text.match(/^\.h1 Yellow/)) {
text = text.substring(4)
p.className = "h1 Y"
- }
- else if (text.match(/^\.h1 Green/)) {
+ } else if (text.match(/^\.h1 Green/)) {
text = text.substring(4)
p.className = "h1 G"
- }
- else if (text.match(/^\.h1/)) {
+ } else if (text.match(/^\.h1/)) {
text = text.substring(4)
p.className = "h1"
- }
- else if (text.match(/^\.h2/)) {
+ } else if (text.match(/^\.h2/)) {
text = text.substring(4)
p.className = "h2"
- }
- else if (text.match(/^\.h3/)) {
+ } else if (text.match(/^\.h3/)) {
text = text.substring(4)
p.className = "h3"
}
+ // Group pretender messages
+
+ if (text.match(/^Pretender\.$/) || text.match(/^Occupied /)) {
+ log_pretender = 1
+ p.classList.add("h2")
+ text = text.replace(".", "")
+ }
+ if (log_pretender === 1 && text === "")
+ log_pretender = 0
+ if (log_pretender)
+ p.classList.add("group", "populace")
+
+ // Group combat messages
+
+ if (text.match(/^Battle in /)) {
+ p.classList.add("h2")
+ log_combat = 2
+ }
+ if (log_combat > 0) {
+ if (
+ text === "DEFENDER" ||
+ text === "ATTACKER" ||
+ text === "FLANKING MANEUVER" ||
+ text === "SPICULUM" ||
+ text === "RESULT"
+ )
+ p.classList.add("h3")
+ if (text === "RESULT")
+ log_combat = 1
+ }
+ if (log_combat === 1 && text === "")
+ log_combat = 0
+ if (log_combat)
+ p.classList.add("group", "military")
+
+ // Group place governor
+
+ if (text.match(/^Place Governor in /) || text.match(/^Praetorian Guard in /)) {
+ log_place = 1
+ p.classList.add("h2")
+ text = text.replace(".", "")
+ }
+ if (log_place === 1 && text === "")
+ log_place = 0
+ if (log_place)
+ p.classList.add("group", "senate")
+
p.innerHTML = text
return p
}
diff --git a/rules.js b/rules.js
index cbc9b3f..f970bb6 100644
--- a/rules.js
+++ b/rules.js
@@ -2700,7 +2700,7 @@ states.damnatio_memoriae = {
},
card(c) {
push_undo()
- log("Damnatio Memoriae.")
+ log_h3("Damnatio Memoriae.")
set_add(game.used, c)
play_card_event(c)
},
@@ -3077,6 +3077,10 @@ states.replace_pretender_governor = {
}
function end_occupation_of_pretender_capital() {
+ if (game.combat) {
+ end_combat()
+ return
+ }
log_br()
resume_take_actions()
}
@@ -4523,8 +4527,7 @@ states.combat_victory = {
}
function goto_combat_victory() {
- log_br()
- log("RESULT")
+ log_h3("RESULT")
let de = is_defender_eliminated()
let ae = is_attacker_eliminated()
if (de && ae)