Skip to content

Commit

Permalink
move my file out of the folder in order for the index.html to be reco…
Browse files Browse the repository at this point in the history
…gnized
  • Loading branch information
VickyJacob23 committed Jul 21, 2024
1 parent 2418690 commit 94b710f
Show file tree
Hide file tree
Showing 14 changed files with 840 additions and 0 deletions.
File renamed without changes.
36 changes: 36 additions & 0 deletions .history/index_20240722002755.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" href="style.css" />
<title>Pig Game</title>
</head>
<body>
<main>
<section class="player player--0 player--active">
<h2 class="name" id="name--0">Player 1</h2>
<p class="score" id="score--0">43</p>
<div class="current">
<p class="current-label">Current</p>
<p class="current-score" id="current--0">0</p>
</div>
</section>
<section class="player player--1">
<h2 class="name" id="name--1">Player 2</h2>
<p class="score" id="score--1">24</p>
<div class="current">
<p class="current-label">Current</p>
<p class="current-score" id="current--1">0</p>
</div>
</section>

<img src="/dice-game-main/image/dice-5.png" alt="Playing dice" class="dice" />
<button class="btn btn--new">🔄 New game</button>
<button class="btn btn--roll">🎲 Roll dice</button>
<button class="btn btn--hold">📥 Hold</button>
</main>
<script src="script.js"></script>
</body>
</html>
File renamed without changes.
96 changes: 96 additions & 0 deletions .history/script_20240722002907.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
'use strict';


// Selecting elements
const player0El = document.querySelector('.player--0');
const player1El = document.querySelector('.player--1');
const score0El = document.getElementById('score--0');
const score1El = document.getElementById('score--1');
const current0El = document.getElementById('current--0');
const current1El = document.getElementById('current--1');

const diceEl = document.querySelector('.dice');
const btnNew = document.querySelector('.btn--new');
const btnRoll = document.querySelector('.btn--roll');
const btnHold = document.querySelector('.btn--hold');

let scores, currentScore, activePlayer, playing;

// Start conditions
const init = function () {
scores = [0, 0];
currentScore = 0;
activePlayer = 0;
playing = true;

score0El.textContent = 0;
score1El.textContent = 0;
current0El.textContent = 0;
current1El.textContent = 0;

diceEl.classList.add('hidden');
player0El.classList.remove('player--winner');
player1El.classList.remove('player--winner');
player0El.classList.add('player--active');
player1El.classList.remove('player--active');
};
init();

const switchPlayer = function () {
document.getElementById(`current--${activePlayer}`).textContent = 0;
currentScore = 0;
activePlayer = activePlayer === 0 ? 1 : 0;
player0El.classList.toggle('player--active');
player1El.classList.toggle('player--active');
};

// Rolling dice functions
btnRoll.addEventListener('click', function () {
if (playing) {

const dice = Math.trunc(Math.random() * 6) + 1;


diceEl.classList.remove('dice');
diceEl.src = `dice-${dice}.png`;

if (dice !== 1) {
// Add dice to current score
currentScore += dice;
document.getElementById(
`current--${activePlayer}`
).textContent = currentScore;
} else {
// next player
switchPlayer();
}
}
});

btnHold.addEventListener('click', function () {
if (playing) {
scores[activePlayer] += currentScore;

document.getElementById(`score--${activePlayer}`).textContent =
scores[activePlayer];

if (scores[activePlayer] >= 100) {
// end game
playing = false;
diceEl.classList.add('hidden');

document
.querySelector(`.player--${activePlayer}`)
.classList.add('player--winner');
document
.querySelector(`.player--${activePlayer}`)
.classList.remove('player--active');
} else {
// next player
switchPlayer();
}
}
});

btnNew.addEventListener('click', init);

96 changes: 96 additions & 0 deletions .history/script_20240722002926.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
'use strict';


// Selecting elements
const player0El = document.querySelector('.player--0');
const player1El = document.querySelector('.player--1');
const score0El = document.getElementById('score--0');
const score1El = document.getElementById('score--1');
const current0El = document.getElementById('current--0');
const current1El = document.getElementById('current--1');

const diceEl = document.querySelector('.dice');
const btnNew = document.querySelector('.btn--new');
const btnRoll = document.querySelector('.btn--roll');
const btnHold = document.querySelector('.btn--hold');

let scores, currentScore, activePlayer, playing;

// Start conditions
const init = function () {
scores = [0, 0];
currentScore = 0;
activePlayer = 0;
playing = true;

score0El.textContent = 0;
score1El.textContent = 0;
current0El.textContent = 0;
current1El.textContent = 0;

diceEl.classList.add('hidden');
player0El.classList.remove('player--winner');
player1El.classList.remove('player--winner');
player0El.classList.add('player--active');
player1El.classList.remove('player--active');
};
init();

const switchPlayer = function () {
document.getElementById(`current--${activePlayer}`).textContent = 0;
currentScore = 0;
activePlayer = activePlayer === 0 ? 1 : 0;
player0El.classList.toggle('player--active');
player1El.classList.toggle('player--active');
};

// Rolling dice functions
btnRoll.addEventListener('click', function () {
if (playing) {

const dice = Math.trunc(Math.random() * 6) + 1;


diceEl.classList.remove('dice--hidden');
diceEl.src = `dice-${dice}.png`;

if (dice !== 1) {
// Add dice to current score
currentScore += dice;
document.getElementById(
`current--${activePlayer}`
).textContent = currentScore;
} else {
// next player
switchPlayer();
}
}
});

btnHold.addEventListener('click', function () {
if (playing) {
scores[activePlayer] += currentScore;

document.getElementById(`score--${activePlayer}`).textContent =
scores[activePlayer];

if (scores[activePlayer] >= 100) {
// end game
playing = false;
diceEl.classList.add('hidden');

document
.querySelector(`.player--${activePlayer}`)
.classList.add('player--winner');
document
.querySelector(`.player--${activePlayer}`)
.classList.remove('player--active');
} else {
// next player
switchPlayer();
}
}
});

btnNew.addEventListener('click', init);

96 changes: 96 additions & 0 deletions .history/script_20240722003113.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
'use strict';


// Selecting elements
const player0El = document.querySelector('.player--0');
const player1El = document.querySelector('.player--1');
const score0El = document.getElementById('score--0');
const score1El = document.getElementById('score--1');
const current0El = document.getElementById('current--0');
const current1El = document.getElementById('current--1');

const diceEl = document.querySelector('.dice');
const btnNew = document.querySelector('.btn--new');
const btnRoll = document.querySelector('.btn--roll');
const btnHold = document.querySelector('.btn--hold');

let scores, currentScore, activePlayer, playing;

// Start conditions
const init = function () {
scores = [0, 0];
currentScore = 0;
activePlayer = 0;
playing = true;

score0El.textContent = 0;
score1El.textContent = 0;
current0El.textContent = 0;
current1El.textContent = 0;

diceEl.classList.add('hidden');
player0El.classList.remove('player--winner');
player1El.classList.remove('player--winner');
player0El.classList.add('player--active');
player1El.classList.remove('player--active');
};
init();

const switchPlayer = function () {
document.getElementById(`current--${activePlayer}`).textContent = 0;
currentScore = 0;
activePlayer = activePlayer === 0 ? 1 : 0;
player0El.classList.toggle('player--active');
player1El.classList.toggle('player--active');
};

// Rolling dice functions
btnRoll.addEventListener('click', function () {
if (playing) {

const dice = Math.trunc(Math.random() * 6) + 1;


// diceEl.classList.remove('dice--hidden');
diceEl.src = `dice-${dice}.png`;

if (dice !== 1) {
// Add dice to current score
currentScore += dice;
document.getElementById(
`current--${activePlayer}`
).textContent = currentScore;
} else {
// next player
switchPlayer();
}
}
});

btnHold.addEventListener('click', function () {
if (playing) {
scores[activePlayer] += currentScore;

document.getElementById(`score--${activePlayer}`).textContent =
scores[activePlayer];

if (scores[activePlayer] >= 100) {
// end game
playing = false;
// diceEl.classList.add('hidden');

document
.querySelector(`.player--${activePlayer}`)
.classList.add('player--winner');
document
.querySelector(`.player--${activePlayer}`)
.classList.remove('player--active');
} else {
// next player
switchPlayer();
}
}
});

btnNew.addEventListener('click', init);

Loading

0 comments on commit 94b710f

Please sign in to comment.