summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-06-26 11:24:34 +0200
committerTor Andersson <tor@ccxvii.net>2023-07-07 19:05:52 +0200
commit09bec88e3ad8894217f4f426372e9d94b2ad1ba9 (patch)
tree7043574f679b3057bcf18eaff94ade0f94ca6c43 /play.js
parent7fdc9800cef0b86c6dc77ed799a7d35904593b1e (diff)
downloadtime-of-crisis-09bec88e3ad8894217f4f426372e9d94b2ad1ba9.tar.gz
Highlight current crisis and player on the crisis table.
Diffstat (limited to 'play.js')
-rw-r--r--play.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/play.js b/play.js
index 90056c6..710610a 100644
--- a/play.js
+++ b/play.js
@@ -3,7 +3,7 @@
// TODO: battle dialog popup for rolling and assigning hits!
// TODO: show killed leaders taken for bonus purchase
-const DICE = {
+const ICONS = {
B0: '<span class="black d0"></span>',
B1: '<span class="black d1"></span>',
B2: '<span class="black d2"></span>',
@@ -691,6 +691,7 @@ let ui = {
amphitheater: [],
basilica: [],
limes: [],
+ crisis: document.getElementById("crisis_highlight"),
dice: [
document.getElementById("crisis_die_1"),
document.getElementById("crisis_die_2"),
@@ -734,10 +735,6 @@ function hide(elt) {
elt.classList.add("hide")
}
-function toggle_pieces() {
- ui.pieces.classList.toggle("hide")
-}
-
function create(t, p, ...c) {
let e = document.createElement(t)
Object.assign(e, p)
@@ -1377,6 +1374,7 @@ function on_update() {
ui.body.classList.toggle("populace", view.color === 2)
layout_barbarian_dice(ui.dice[2], ui.dice[3], view.crisis[0])
+ ui.crisis.className = "p_" + PLAYER_CLASS[view.current] + " c" + (view.crisis[1] + view.crisis[2])
ui.dice[0].className = "dice black d" + view.crisis[1]
ui.dice[1].className = "dice white d" + view.crisis[2]
ui.dice[2].className = "dice black d" + view.crisis[3]
@@ -1477,8 +1475,16 @@ function sub_event_name(match, p1) {
return EVENT_NAME[x]
}
-function sub_dice_image(match) {
- return DICE[match]
+function sub_icon(match) {
+ return ICONS[match]
+}
+
+function sub_card_1(match) {
+ return match
+}
+
+function sub_card_x(match, p1, p2) {
+ return p1 + "\xa0" + p2
}
function on_log(text) {
@@ -1495,7 +1501,9 @@ function on_log(text) {
text = text.replace(/%(\d+)/g, sub_region_name)
text = text.replace(/\bE(\d+)/g, sub_event_name)
- text = text.replace(/\b[BW]\d\b/g, sub_dice_image)
+ text = text.replace(/\b[BW]\d\b/g, sub_icon)
+ text = text.replace(/\b[MSP][1]\b/g, sub_card_1)
+ text = text.replace(/\b([MSP][234])\(([^)]*)\)/g, sub_card_x)
if (text.match(/^.turn/)) {
text = text.substring(6)