Change buttons a bit. End turn option
This commit is contained in:
@ -34,31 +34,19 @@ function updateMapDom() {
|
||||
}
|
||||
|
||||
if (gameState === PRE_GAME) {
|
||||
if (allRegionsClaimed()) {
|
||||
document
|
||||
.querySelectorAll(".actions button")
|
||||
.forEach((e) => (e.textContent = "Reinf."));
|
||||
}
|
||||
} else if (gameState === PLAYING) {
|
||||
document.querySelectorAll(".node").forEach((e) => {
|
||||
e.querySelectorAll(".game-action").forEach((el) => {
|
||||
el.remove();
|
||||
});
|
||||
|
||||
let region = Region.getRegion(e.dataset["name"]);
|
||||
for (let n of region.neighbours) {
|
||||
let b = document.createElement("button");
|
||||
b.classList.add("game-action");
|
||||
if (n.owner === us) {
|
||||
b.classList.add("fortify");
|
||||
b.textContent = `Fortify ${n.name}`;
|
||||
} else {
|
||||
b.classList.add("attack");
|
||||
b.textContent = `Attack ${n.name}`;
|
||||
}
|
||||
e.querySelector(".actions").appendChild(b);
|
||||
}
|
||||
document.querySelectorAll(".fortify, .attack").forEach((e) => {
|
||||
e.classList.add("hidden");
|
||||
});
|
||||
} else if (gameState === PLAYING) {
|
||||
document.querySelectorAll(".node button").forEach((e) => {
|
||||
e.classList.remove("hidden");
|
||||
});
|
||||
|
||||
if (us.isPlaying) {
|
||||
document.querySelector("#end-turn").classList.remove("hidden");
|
||||
} else {
|
||||
document.querySelector("#end-turn").classList.add("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
for (let region of Object.values(REGIONS)) {
|
||||
@ -124,6 +112,10 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelector("#end-turn").addEventListener("click", async (ev) => {
|
||||
socket.emit("message", Packet.createEndTurn());
|
||||
});
|
||||
|
||||
document.querySelectorAll(".actions button").forEach((el) =>
|
||||
el.addEventListener("click", (ev) => {
|
||||
let region = ev.target.closest(".node").dataset.name;
|
||||
|
@ -46,4 +46,11 @@ class Packet {
|
||||
region: region,
|
||||
};
|
||||
}
|
||||
|
||||
static createEndTurn() {
|
||||
return {
|
||||
...this._createBase("ACT"),
|
||||
action: "END",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user