Commit b519acd5 authored by MohammadAli Keshavarz's avatar MohammadAli Keshavarz

add comment and add functionality to hold btn

parent b47fc125
......@@ -20,12 +20,16 @@ activePlayer = 0;
// var x = document.querySelector("#score-1").textContent;
// console.log(x);
// make dice invisible
document.querySelector(".dice").style.display = "none";
document.getElementById('current-0').textContent = "0" ;
document.getElementById('current-1').textContent = "0" ;
document.getElementById('score-0').textContent = "0" ;
document.getElementById('score-1').textContent = "0" ;
// initializing user inteface
document.getElementById("current-0").textContent = "0";
document.getElementById("current-1").textContent = "0";
document.getElementById("score-0").textContent = "0";
document.getElementById("score-1").textContent = "0";
// add functionality for roll btn
document.querySelector(".btn-roll").addEventListener("click", function() {
//create random number
var dice = Math.floor(Math.random() * 6) + 1;
......@@ -45,8 +49,37 @@ document.querySelector(".btn-roll").addEventListener("click", function() {
activePlayer = 0;
document.querySelector("#current-1").textContent = 0;
}
document.querySelector('.player-0-panel').classList.toggle('active');
document.querySelector('.player-1-panel').classList.toggle('active');
// make dice invisible
document.querySelector(".dice").style.display = "none";
//change active theme
document.querySelector(".player-0-panel").classList.toggle("active");
document.querySelector(".player-1-panel").classList.toggle("active");
}
// change current score in user inteface
document.querySelector("#current-" + activePlayer).textContent = roundScore;
});
// add functionality for hold btn
document.querySelector(".btn-hold").addEventListener("click", function() {
scores[activePlayer] += roundScore;
document.getElementById("score-" + activePlayer).textContent =
scores[activePlayer];
roundScore = 0;
if (activePlayer === 0) {
activePlayer = 1;
document.querySelector("#current-0").textContent = 0;
} else {
activePlayer = 0;
document.querySelector("#current-1").textContent = 0;
}
// make dice invisible
document.querySelector(".dice").style.display = "none";
//change active theme
document.querySelector(".player-0-panel").classList.toggle("active");
document.querySelector(".player-1-panel").classList.toggle("active");
});
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