From 779ee568c78238027d86028c39beb7b6bf959ab7 Mon Sep 17 00:00:00 2001 From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com> Date: Tue, 7 Nov 2023 15:25:58 +0100 Subject: congress and turn ui --- play.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'play.js') diff --git a/play.js b/play.js index eb8d8f2..584ba34 100644 --- a/play.js +++ b/play.js @@ -30,6 +30,9 @@ const card_count = 128 let ui = { status: document.getElementById("status"), + turn: document.getElementById("turn"), + congress_box: document.getElementById("congress_box"), + congress: [ null ], player: [ document.getElementById("role_Suffragist"), document.getElementById("role_Opposition"), @@ -239,6 +242,15 @@ function on_click_card(evt) { } } +function on_click_congress(evt) { + if (evt.button === 0) { + console.log("congress") + if (send_action('congress')) + evt.stopPropagation() + } + hide_popup_menu() +} + function on_click_region(evt) { if (evt.button === 0) { if (send_action('region', evt.target.my_region)) @@ -282,6 +294,15 @@ function create(t, p, ...c) { function build_user_interface() { let elt + ui.congress_box.onmousedown = on_click_congress + for (let c = 1; c <= 6; ++c) { + elt = ui.congress[c] = create("div", { + className: "piece congress", + style: `left:${10 + (c-1) * 42}px;top:5px;`, + onmousedown: on_click_congress + }) + } + for (let c = 1; c <= card_count; ++c) { elt = ui.cards[c] = create("div", { className: `card card_${c}`, @@ -381,6 +402,15 @@ function on_update() { // eslint-disable-line no-unused-vars document.getElementById("support_info").textContent = support_info() document.getElementById("opposition_info").textContent = opposition_info() + ui.turn.style.left = 800 + (42 * (view.turn - 1)) + "px" + + ui.congress_box.replaceChildren() + ui.congress_box.classList.toggle("action", !view.congress && is_action("congress")) + for (let c = 1; c <= view.congress; ++c) { + ui.congress_box.appendChild(ui.congress[c]) + ui.congress[c].classList.toggle("action", is_action("congress")) + } + document.getElementById("hand").replaceChildren() document.getElementById("support_claimed").replaceChildren() document.getElementById("support_discard").replaceChildren() -- cgit v1.2.3