From 7d433c1821d431d2a268d099eecdee71ca386110 Mon Sep 17 00:00:00 2001 From: Ken Vilar Date: Sun, 3 Dec 2017 15:44:05 +0800 Subject: [PATCH] Change to other player when dice is 1 and reset the roundScore to 0 --- main.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 26015bd..b8bf252 100644 --- a/main.js +++ b/main.js @@ -33,8 +33,18 @@ document.querySelector('.btn-roll-dice').addEventListener('click', function () { document.querySelector('#current-' + activePlayer).textContent = roundScore; } else { //Next player - document.querySelector('#current-' + activePlayer).textContent = '0'; + document.getElementById('current-1').textContent = '0'; + document.getElementById('current-2').textContent = '0'; + + roundScore = 0; + activePlayer === 1 ? activePlayer = 2 : activePlayer = 1; + + 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'; } });