Add event to just update strength numbers

This commit is contained in:
jude 2023-04-06 12:18:21 +01:00
parent 9d1d64f1d9
commit f645c234ce
2 changed files with 8 additions and 2 deletions

View File

@ -56,16 +56,21 @@ function updateMapDom() {
}
}
showStrengths();
showRemainingReinforcements();
}
function showStrengths() {
for (let region of Region.getAllRegions()) {
const element = document.querySelector(`.node[data-name=${region.name}]`);
element.querySelector(".strength").textContent = region.displayStrength();
element.style.backgroundColor =
region.owner === null ? "white" : region.owner.getColor();
}
showRemainingReinforcements();
}
document.addEventListener("updateStrengths", showStrengths);
document.addEventListener("gameStateUpdate", () => {
if (!game.isWaiting()) {
document.querySelector("#ready-button").style.display = "none";

View File

@ -79,6 +79,7 @@ class Strength {
let result = proofSessionVerifier.verify(BigInt(data.z));
if (result > 0) {
this.assumedStrength = plainText;
document.dispatchEvent(new CustomEvent("updateStrengths"));
controller.abort();
} else {
console.warn(`Failed to verify ciphertext! ${result}`);