Skip to content

Commit

Permalink
Only one dice; the two dice game will be in separate game rule
Browse files Browse the repository at this point in the history
  • Loading branch information
kenvilar committed Dec 3, 2017
1 parent 87e530f commit a044cec
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ document.querySelector('.btn-roll-dice').addEventListener('click', function () {
var dice = Math.floor((Math.random() * 6) + 1);

//Display result
var diceObj1 = document.querySelector('#dice-1');
var diceObj2 = document.querySelector('#dice-2');
var diceObj = document.querySelector('.dice');

diceObj1.style.display = 'block';
diceObj2.style.display = 'block';
diceObj.style.display = 'block';

diceObj1.src = 'dice' + dice + '.png';
diceObj2.src = 'dice' + dice + '.png';
diceObj.src = 'dice' + dice + '.png';

//Update round score if the rolled number is not 1
if (dice !== 1) {
Expand All @@ -41,8 +38,7 @@ document.querySelector('.btn-hold').addEventListener('click', function () {
//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('.dice').style.display = 'none';

document.querySelector('.player-' + activePlayer + '-panel').classList.add('winner');
document.querySelector('.player-' + activePlayer + '-panel').classList.remove('active');
Expand All @@ -67,8 +63,7 @@ function nextPlayer() {
document.querySelector('.player-1-panel').classList.toggle('active');
document.querySelector('.player-2-panel').classList.toggle('active');

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

function reset() {
Expand Down Expand Up @@ -97,8 +92,3 @@ function reset() {

document.querySelector('.player-' + activePlayer + '-panel').classList.add('active');
}


///////
// document.querySelector('#current-' + activePlayer).textContent = dice; //Select the element
//document.querySelector('#current-' + activePlayer).innerHTML = '<em>' + dice + '</em>';

0 comments on commit a044cec

Please sign in to comment.