Skip to content

Commit

Permalink
Remove the build in gitignore.
Browse files Browse the repository at this point in the history
  • Loading branch information
L3on06 committed Feb 26, 2024
1 parent 54ac47a commit f30faba
Show file tree
Hide file tree
Showing 21 changed files with 428 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.snowpack
build
node_modules
88 changes: 88 additions & 0 deletions build/dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
let player1 = "";
let player2 = "";
let namesEntered = false;
const buttonStart = document.querySelector("#buttonstart");
const buttonEnd = document.querySelector("#buttonend");
function validateNameType(playerName) {
const regex = /^[a-zA-Z]+$/;
return regex.test(playerName);
}
function validateNameZeroSymbol(playerName) {
const regex = /^[a-zA-Z\s]*$/;
return regex.test(playerName);
}
if (buttonStart && buttonEnd) {
buttonStart.addEventListener("click", function() {
if (!namesEntered) {
player1 = prompt("What is your name Player 1") || "";
player2 = prompt("What is your name Player 2") || "";
while (true) {
if (player1.length > 0 && player1.length <= 10 && validateNameType(player1) && validateNameZeroSymbol(player1) && player2.length > 0 && player2.length <= 10 && validateNameType(player2) && validateNameZeroSymbol(player2)) {
namesEntered = true;
break;
} else {
if (player1.length === 0 || player1.length > 10 || !validateNameType(player1) || !validateNameZeroSymbol(player1)) {
player1 = prompt("Invalid input for Player 1. Please enter a valid name (up to 10 characters, only letters, no symbols)") || "";
}
if (player2.length === 0 || player2.length > 10 || !validateNameType(player2) || !validateNameZeroSymbol(player2)) {
player2 = prompt("Invalid input for Player 2. Please enter a valid name (up to 10 characters, only letters, no symbols)") || "";
}
}
}
const player1Name = document.getElementById("Player1Name");
const player2Name = document.getElementById("Player2Name");
if (player1Name && player2Name) {
player1Name.innerHTML = player1;
player2Name.innerHTML = player2;
}
}
if (buttonStart && buttonEnd) {
buttonStart.style.display = "none";
buttonEnd.style.display = "block";
const dice_shake = new Audio("./source/audio/dice_shake.mp3");
dice_shake.play();
const a1 = document.querySelector(".img1");
const a2 = document.querySelector(".img2");
if (a1 && a2) {
a1.style.animation = "rotate-center 1s linear both infinite";
a2.style.animation = "rotate-center 1s linear both infinite";
}
}
});
buttonEnd.addEventListener("click", () => {
if (buttonEnd && buttonStart) {
buttonEnd.style.display = "none";
buttonStart.style.display = "block";
const dice_roll = new Audio("./source/audio/dice_roll.mp3");
dice_roll.play();
const randomNumber1 = Math.floor(Math.random() * 6) + 1;
const randomImageSource = "./source/images/dice" + randomNumber1 + ".png";
const image1 = document.querySelector(".img1");
if (image1) {
image1.setAttribute("src", randomImageSource);
}
const randomNumber2 = Math.floor(Math.random() * 6) + 1;
const randomImageSource2 = "./source/images/diceR" + randomNumber2 + ".png";
const image2 = document.querySelector(".img2");
if (image2) {
image2.setAttribute("src", randomImageSource2);
}
const headingElement = document.querySelector("h1");
if (headingElement) {
if (randomNumber1 > randomNumber2) {
headingElement.innerHTML = "🎉🏆🎉" + player1 + " Wins!";
} else if (randomNumber2 > randomNumber1) {
headingElement.innerHTML = player2 + " Wins 🎉🏆🎉";
} else {
headingElement.innerHTML = "Draw!";
}
}
const a1 = document.querySelector(".img1");
const a2 = document.querySelector(".img2");
if (a1 && a2) {
a1.style.animation = "rotate-end 1s ease-in-out both ";
a2.style.animation = "rotate-end 1s ease-in-out both ";
}
}
});
}
81 changes: 81 additions & 0 deletions build/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!-- Title -->
<title> 🎲 Dicee 🎲 </title>

<!-- Favicon -->
<link rel="icon" href="./source/images/logo.png">

<!-- Google Fonts -->
<link
href="https://fonts.googleapis.com/css2?family=Chakra+Petch&family=DynaPuff&family=Rubik+Dirt&family=Silkscreen&display=swap"
rel="stylesheet">

<!-- Style -->
<link rel="stylesheet" href="./source/styles/index.css">

<!-- Javascript -->
<script type="module" src="/dist/index.js"></script>
</head>

<body>
<div class="container">
<header class="dgrid">
<h1 class="title"> 🎲 &nbsp; Dicee &nbsp; 🎲 </h1>
</header>

<main>
<section class="mainContainer ">
<figure class="dice main-animation dgrid">
<figcaption>
<p class="paragraf" id="Player1Name">Player 1</p>
</figcaption>
<img id="imgPlayer1" class="img img1" src="./source/images/dice6.png" alt="Dice">
</figure>

<figure class="dice dgrid">
<figcaption>
<p class="paragraf" id="Player2Name">Player 2</p>
</figcaption>
<img id="imgPlayer2" class="img img2" src="./source/images/diceR6.png" alt="Dice">
</figure>
</section>

<section>
<button id="buttonstart" class="button">Start</button>
<button id="buttonend" class="button">End</button>
</section>

<section class="github">
<a href="https://github.com/L3on06" target="_blank">
<figure>
<img src="./source/images/github.svg" alt="Github">
</figure>
</a>
</section>
</main>

<!-- Background animation -->
<ul class="circles">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>

</body>


</html>
3 changes: 3 additions & 0 deletions build/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
Binary file added build/source/audio/dice_roll.mp3
Binary file not shown.
Binary file added build/source/audio/dice_shake.mp3
Binary file not shown.
Binary file added build/source/images/dice1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/source/images/dice2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/source/images/dice3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/source/images/dice4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/source/images/dice5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/source/images/dice6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/source/images/diceR1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/source/images/diceR2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/source/images/diceR3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/source/images/diceR4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/source/images/diceR5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/source/images/diceR6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions build/source/images/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/source/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f30faba

Please sign in to comment.