Commit a517dc4c authored by MohammadAli Keshavarz's avatar MohammadAli Keshavarz

find winner player :)

parent c5c021b2
...@@ -66,7 +66,6 @@ document.querySelector(".btn-roll").addEventListener("click", function() { ...@@ -66,7 +66,6 @@ document.querySelector(".btn-roll").addEventListener("click", function() {
// add functionality for hold btn // add functionality for hold btn
document.querySelector(".btn-hold").addEventListener("click", function() { document.querySelector(".btn-hold").addEventListener("click", function() {
//update score //update score
scores[activePlayer] += roundScore; scores[activePlayer] += roundScore;
...@@ -74,6 +73,14 @@ document.querySelector(".btn-hold").addEventListener("click", function() { ...@@ -74,6 +73,14 @@ document.querySelector(".btn-hold").addEventListener("click", function() {
document.getElementById("score-" + activePlayer).textContent = document.getElementById("score-" + activePlayer).textContent =
scores[activePlayer]; scores[activePlayer];
//change player //find winner!
changePlayer(); if (scores[activePlayer] >= 20) {
document.getElementById("name-" + activePlayer).textContent = "Winner! :)";
document.querySelector('.dice').style.display = "none";
document.querySelector(".player-"+activePlayer+"-panel").classList.remove('active');
document.querySelector(".player-"+activePlayer+"-panel").classList.add('winner');
} else {
//change player
changePlayer();
}
}); });
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