From d4ede91cf06b0d544afea4b5f3aa1c2040cc803d Mon Sep 17 00:00:00 2001 From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com> Date: Fri, 24 Nov 2023 11:19:30 +0100 Subject: show persistent cards as stack --- play.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'play.js') diff --git a/play.js b/play.js index 13980e2..f4a1aa4 100644 --- a/play.js +++ b/play.js @@ -655,18 +655,16 @@ function on_update() { // eslint-disable-line no-unused-vars for (let c of view.out_of_play) document.getElementById("out_of_play").appendChild(ui.cards[c]) - // TODO Replace with stacked cards for (let id of ['persistent_turn', 'persistent_game', 'persistent_ballot']) { - document.getElementById(id).replaceChildren() - for (let c of view[id] || []) { - let elt = create("div", { - className: `persistent_card ${CARDS[c].type}`, - innerHTML: sub_card_name(null, c), - my_card: c - }) - elt.addEventListener("click", on_click_card) - elt.classList.toggle("action", is_card_enabled(c)) - document.getElementById(id).appendChild(elt) + const container = document.getElementById(id) + container.replaceChildren() + const stack = view[id] || [] + for (let i = 0; i < stack.length; ++i) { + const c = stack[i] + const elt = ui.cards[c] + elt.style.top = -85 * i + "px" + elt.style.zIndex = i + 10 + container.appendChild(elt) } } -- cgit v1.2.3