Skip to content

Commit

Permalink
Make it one line code consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
kenvilar committed Dec 3, 2017
1 parent e042311 commit 8eaa6e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
12 changes: 6 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
<div class="wrapper clearfix">

<div class="player-1-panel active">
<div class="player-name" id="name-1">PLAYER 1</div>
<div class="player-score" id="score-1">0</div>
<div class="player-name" id="name-1"></div>
<div class="player-score" id="score-1"></div>
<div class="player-current-box">
<div class="player-current-label">Current</div>
<div class="player-current-score" id="current-1">0</div>
<div class="player-current-score" id="current-1"></div>
</div>
</div>

<div class="player-2-panel">
<div class="player-name" id="name-2">PLAYER 2</div>
<div class="player-score" id="score-2">0</div>
<div class="player-name" id="name-2"></div>
<div class="player-score" id="score-2"></div>
<div class="player-current-box">
<div class="player-current-label">Current</div>
<div class="player-current-score" id="current-2">0</div>
<div class="player-current-score" id="current-2"></div>
</div>
</div>

Expand Down
25 changes: 18 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,29 @@ scores = [0, 0]; // Player 1 and Player 2
roundScore = 0; // Initial Score for round score
activePlayer = 1; // Current active player

document.querySelector('#dice-1').style.display = 'none';
document.querySelector('#dice-2').style.display = 'none';
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.getElementById('score-1').textContent = '0';
document.getElementById('score-2').textContent = '0';
document.getElementById('current-1').textContent = '0';
document.getElementById('current-2').textContent = '0';

document.querySelector('.btn-roll-dice').addEventListener('click', function () {
/* TODO */
//Random number
var dice = Math.floor((Math.random() * 6) + 1);
//Display result
document.querySelector('#dice-1').style.display = 'block';
document.querySelector('#dice-2').style.display = 'block';
document.querySelector('#dice-1').src = 'dice' + dice + '.png';
document.querySelector('#dice-2').src = 'dice' + dice + '.png';
var diceObj1 = document.querySelector('#dice-1');
var diceObj2 = document.querySelector('#dice-2');
diceObj1.style.display = 'block';
diceObj2.style.display = 'block';
diceObj1.src = 'dice' + dice + '.png';
diceObj2.src = 'dice' + dice + '.png';
/* TODO */
//Update round score if the rolled number is not 1
});


Expand Down

0 comments on commit 8eaa6e0

Please sign in to comment.