Skip to content

Commit

Permalink
Update round score if rolled number is not 1; Hide obvious comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kenvilar committed Dec 3, 2017
1 parent 8eaa6e0 commit 3c8193f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ activePlayer = 1; // Current active player
document.querySelector('#name-1').textContent = 'PLAYER 1';
document.querySelector('#name-2').textContent = 'PLAYER 2';

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

document.getElementById('score-1').textContent = '0';
document.getElementById('score-2').textContent = '0';
Expand All @@ -27,6 +27,19 @@ document.querySelector('.btn-roll-dice').addEventListener('click', function () {
diceObj2.src = 'dice' + dice + '.png';
/* TODO */
//Update round score if the rolled number is not 1
if (dice !== 1) {
//Add score
roundScore = roundScore + dice;
document.querySelector('#current-' + activePlayer).textContent = roundScore;
} else {
//Next player
document.querySelector('#current-' + activePlayer).textContent = '0';
if (activePlayer === 1) {
activePlayer = 2;
} else {
activePlayer = 1;
}
}
});


Expand Down

0 comments on commit 3c8193f

Please sign in to comment.