From 09bec88e3ad8894217f4f426372e9d94b2ad1ba9 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 26 Jun 2023 11:24:34 +0200 Subject: Highlight current crisis and player on the crisis table. --- play.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'play.js') 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: '', B1: '', B2: '', @@ -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) -- cgit v1.2.3