From e8624e0dc41171c01816ecbeb09a6e5c6475f1ca Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 3 Jun 2024 11:16:12 +0200 Subject: fix client glitch with number badge when pieces are removed --- play.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'play.js') diff --git a/play.js b/play.js index 965e363..4063a5a 100644 --- a/play.js +++ b/play.js @@ -850,16 +850,15 @@ function get_cylinder_power(id) { } function layout_general(id, s) { - let e = ui.pieces[id] let x, y, n if (s === REMOVED) { - if (e.parentElement === ui.pieces_element) - e.remove() + if (ui.pieces[id].parentElement === ui.pieces_element) + ui.pieces[id].remove() + if (ui.troops[id].parentElement === ui.pieces_element) + ui.troops[id].remove() return } - if (e.parentElement !== ui.pieces_element) - ui.pieces_element.appendChild(e) if (s === ELIMINATED) { n = layout_general_offset_elim(id) @@ -875,6 +874,9 @@ function layout_general(id, s) { let selected = set_has(view.selected, id) + let e = ui.pieces[id] + if (e.parentElement !== ui.pieces_element) + ui.pieces_element.appendChild(e) e.style.left = (x - 21) + "px" e.style.top = (y - 29 - 15 * n) + "px" e.style.zIndex = y + n @@ -882,10 +884,9 @@ function layout_general(id, s) { e.classList.toggle("oos", (view.oos & (1 <