show defending region

This commit is contained in:
jude 2023-02-18 16:48:31 +00:00
parent 70b4857933
commit 62204634e1
3 changed files with 10 additions and 7 deletions

View File

@ -4,6 +4,7 @@
top: 0; top: 0;
padding: 12px; padding: 12px;
z-index: 2; z-index: 2;
font-family: monospace;
} }
#ready { #ready {

View File

@ -190,10 +190,10 @@ document.addEventListener("DOMContentLoaded", () => {
socket.emit("message", Packet.createDefense(amount)); socket.emit("message", Packet.createDefense(amount));
}); });
document document.querySelectorAll(".submit-modal, .cancel-modal").forEach((el) => {
.querySelector(".submit-modal, .cancel-modal") el.addEventListener("click", () => {
.addEventListener("click", (el) => { el.closest(".modal").classList.add("hidden");
el.target.closest(".modal").classList.add("hidden"); });
}); });
document.querySelector("#shuffleColors").addEventListener("click", () => { document.querySelector("#shuffleColors").addEventListener("click", () => {
@ -218,6 +218,8 @@ function showRemainingReinforcements() {
} }
} }
function showDefenseDom() { function showDefenseDom(region) {
document.querySelector("#defense-modal").classList.remove("hidden"); const modal = document.querySelector("#defense-modal");
modal.querySelector("span").textContent = region;
modal.classList.remove("hidden");
} }

View File

@ -148,7 +148,7 @@ class Player {
// If we're the defender, we need to send a packet to state our defense. // If we're the defender, we need to send a packet to state our defense.
if (defender.owner === us) { if (defender.owner === us) {
showDefenseDom(); showDefenseDom(defender.name);
} }
// Grab the defense amount from // Grab the defense amount from