diff --git a/javascript/game.js b/javascript/game.js
index 4b0b485..4932124 100644
--- a/javascript/game.js
+++ b/javascript/game.js
@@ -204,6 +204,7 @@ function renderGame() {
}
function renderDeadAndAliveInformation() {
+ // TODO: Refactor this function.
let infoContainer = document.getElementById("info-container");
let alivePlayers = currentGame.players.filter((player) => !player.dead).sort((a, b) =>
{
@@ -235,7 +236,7 @@ function renderDeadAndAliveInformation() {
let aliveHeader = document.createElement("h2");
aliveContainer.appendChild(aliveHeader);
aliveHeader.innerText = "Roles Still Alive";
- var rollCounter={}; //RTM
+ var rollCounter = {}; // RTM
alivePlayers.forEach((player) => {
let alivePlayerClass = player.card.team === "good" ? "alive-player-village" : "alive-player-evil";
if (player.card.isTypeOfWerewolf) {
@@ -243,21 +244,21 @@ function renderDeadAndAliveInformation() {
}
//RTM
if (rollCounter.hasOwnProperty(player.card.role)) {
- rollCounter[player.card.role]+=1;
+ rollCounter[player.card.role] += 1;
}
else {
- rollCounter[player.card.role]=1;
+ rollCounter[player.card.role] = 1;
//RTM
const alivePlayer = document.createElement("div");
alivePlayer.setAttribute("class", "alive-player " + alivePlayerClass);
alivePlayer.innerHTML = "
" + player.card.role + "
";
- let roleCount=document.createElement("span");//RTM
+ let roleCount = document.createElement("span"); // RTM
roleCount.setAttribute("class","rolecount");
//Add hidden description span - RTM 4/18/2020
let playerCardInfo=document.createElement("span");
playerCardInfo.setAttribute("class","tooltiptext");
playerCardInfo.innerText=player.card.description;
- alivePlayer.appendChild(roleCount);
+ alivePlayer.prepend(roleCount);
alivePlayer.appendChild(playerCardInfo);
aliveContainer.appendChild(alivePlayer);
}
@@ -268,18 +269,18 @@ function renderDeadAndAliveInformation() {
infoContainer.appendChild(killedContainer);
infoContainer.appendChild(aliveContainer);
document.getElementById("game-container").appendChild(infoContainer);
- //Has to be done AFTER the infoContainer is rendered in the DOM to insert the updated counts
+ // Has to be done AFTER the infoContainer is rendered in the DOM to insert the updated counts
for (let x of document.getElementsByClassName("alive-player")) {
- x.getElementsByClassName("rolecount")[0].innerHTML=rollCounter[x.getElementsByTagName("P")[0].innerHTML];
+ x.getElementsByClassName("rolecount")[0].innerText = rollCounter[x.getElementsByTagName("p")[0].innerText];
}
} else {
document.getElementById("killed-container").remove();
document.getElementById("alive-container").remove();
document.getElementById("info-container").append(killedContainer);
document.getElementById("info-container").append(aliveContainer);
- //Has to be done AFTER the infoContainer is rendered in the DOM to insert the updated counts
+ // Has to be done AFTER the infoContainer is rendered in the DOM to insert the updated counts
for (let x of document.getElementsByClassName("alive-player")) {
- x.getElementsByClassName("rolecount")[0].innerHTML=rollCounter[x.getElementsByTagName("P")[0].innerHTML];
+ x.getElementsByClassName("rolecount")[0].innerText = rollCounter[x.getElementsByTagName("p")[0].innerText];
}
}
}
diff --git a/server-helper.js b/server-helper.js
index b7a991a..3ed2a21 100644
--- a/server-helper.js
+++ b/server-helper.js
@@ -37,7 +37,7 @@ module.exports = class {
if (player.card.role === "Werewolf" && game.hasDreamWolf) {
this.activateDreamWolvesIfNeeded(game);
}
- const winCheck = ServerHelper.teamWon(game);
+ const winCheck = module.exports.teamWon(game);
if (winCheck === "wolf") {
console.log("wolves won the game!");
game.winningTeam = "wolf";