Commit acdc1d54 authored by MohammadAli Keshavarz's avatar MohammadAli Keshavarz

change current score with rolling dice

parent a5ef0ece
...@@ -28,8 +28,19 @@ document.querySelector(".btn-roll").addEventListener("click", function() { ...@@ -28,8 +28,19 @@ document.querySelector(".btn-roll").addEventListener("click", function() {
// disply the result // disply the result
var diceDOM = document.querySelector(".dice"); var diceDOM = document.querySelector(".dice");
diceDOM.style.display = "block"; diceDOM.style.display = "block";
diceDOM.src = "./dice-" + dice +".png"; diceDOM.src = "./dice-" + dice + ".png";
// update current scores, if the rolled number was not one // update current scores, if the rolled number was not one
if (dice !== 1) { if (dice !== 1) {
roundScore += dice;
} else {
roundScore = 0;
if (activePlayer === 0) {
activePlayer = 1;
document.querySelector("#current-0").textContent = 0;
} else {
activePlayer = 0;
document.querySelector("#current-1").textContent = 0;
}
} }
document.querySelector("#current-" + activePlayer).textContent = roundScore;
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment