Skip to content

Commit

Permalink
If player wins then add winner classname and remove active classname
Browse files Browse the repository at this point in the history
  • Loading branch information
kenvilar committed Dec 3, 2017
1 parent 7db7266 commit bf5c848
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ document.querySelector('.btn-hold').addEventListener('click', function () {
document.querySelector('#score-' + activePlayer).textContent = scores[activePlayer - 1];

//Check if the player won the game
if (scores[activePlayer - 1] >= 20) {
if (scores[activePlayer - 1] >= 100) {
//id="name-1"
document.querySelector('#name-' + activePlayer).textContent = 'WINNER!';

document.querySelector('#dice-1').style.display = 'none';
document.querySelector('#dice-2').style.display = 'none';

document.querySelector('.player-' + activePlayer + '-panel').classList.add('winner');
document.querySelector('.player-' + activePlayer + '-panel').classList.remove('active');
} else {
nextPlayer();
}
Expand Down

0 comments on commit bf5c848

Please sign in to comment.