Uploading files to github
BIN
BlackJackCards/BACK.png
Normal file
|
After Width: | Height: | Size: 795 KiB |
BIN
BlackJackCards/J-B.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
BlackJackCards/J-R.png
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
Clubs/10.png
Normal file
|
After Width: | Height: | Size: 53 KiB |
BIN
Clubs/2.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
Clubs/3.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
Clubs/4.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
Clubs/5.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
Clubs/6.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
Clubs/7.png
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
Clubs/8.png
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
Clubs/9.png
Normal file
|
After Width: | Height: | Size: 50 KiB |
BIN
Clubs/A.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
Clubs/J.png
Normal file
|
After Width: | Height: | Size: 203 KiB |
BIN
Clubs/K.png
Normal file
|
After Width: | Height: | Size: 257 KiB |
BIN
Clubs/Q.png
Normal file
|
After Width: | Height: | Size: 279 KiB |
BIN
Diamonds/10.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
Diamonds/2.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
Diamonds/3.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
Diamonds/4.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
Diamonds/5.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
Diamonds/6.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
Diamonds/7.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
Diamonds/8.png
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
Diamonds/9.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
Diamonds/A.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
Diamonds/J.png
Normal file
|
After Width: | Height: | Size: 210 KiB |
BIN
Diamonds/K.png
Normal file
|
After Width: | Height: | Size: 260 KiB |
BIN
Diamonds/Q.png
Normal file
|
After Width: | Height: | Size: 191 KiB |
BIN
Hearts/10.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
Hearts/2.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
Hearts/3.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
Hearts/4.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
Hearts/5.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
Hearts/6.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
Hearts/7.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
Hearts/8.png
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
Hearts/9.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
Hearts/A.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
Hearts/J.png
Normal file
|
After Width: | Height: | Size: 255 KiB |
BIN
Hearts/K.png
Normal file
|
After Width: | Height: | Size: 273 KiB |
BIN
Hearts/Q.png
Normal file
|
After Width: | Height: | Size: 238 KiB |
BIN
Spades/10.png
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
Spades/2.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
Spades/3.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
Spades/4.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
Spades/5.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
Spades/6.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
Spades/7.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
Spades/8.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
Spades/9.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
Spades/A.png
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
Spades/J.png
Normal file
|
After Width: | Height: | Size: 242 KiB |
BIN
Spades/K.png
Normal file
|
After Width: | Height: | Size: 197 KiB |
BIN
Spades/Q.png
Normal file
|
After Width: | Height: | Size: 201 KiB |
22
index.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<!-- Links -->
|
||||
<link rel="stylesheet" href="style.css">
|
||||
|
||||
<title>BlackJack</title>
|
||||
</head>
|
||||
<body>
|
||||
<article class="cards cards1"><img src="./BlackJackCards/J-B.png" class="card" alt=""></article>
|
||||
<h2 id="playerScore">69</h2>
|
||||
<article class="cards cards2"><img src="./BlackJackCards/J-R.png" class="card" alt="" id="card"></article>
|
||||
<section>
|
||||
<button onclick="hit()">Hit</button>
|
||||
<button>Stand</button>
|
||||
</section>
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
94
main.js
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
const Deck = {
|
||||
Clubs:[
|
||||
'2.png',
|
||||
'3.png',
|
||||
'4.png',
|
||||
'5.png',
|
||||
'6.png',
|
||||
'7.png',
|
||||
'8.png',
|
||||
'9.png',
|
||||
'10.png',
|
||||
'A.png',
|
||||
'J.png',
|
||||
'K.png',
|
||||
'Q.png',
|
||||
],
|
||||
Diamonds:[
|
||||
'2.png',
|
||||
'3.png',
|
||||
'4.png',
|
||||
'5.png',
|
||||
'6.png',
|
||||
'7.png',
|
||||
'8.png',
|
||||
'9.png',
|
||||
'10.png',
|
||||
'A.png',
|
||||
'J.png',
|
||||
'K.png',
|
||||
'Q.png',
|
||||
],
|
||||
Hearts:[
|
||||
'2.png',
|
||||
'3.png',
|
||||
'4.png',
|
||||
'5.png',
|
||||
'6.png',
|
||||
'7.png',
|
||||
'8.png',
|
||||
'9.png',
|
||||
'10.png',
|
||||
'A.png',
|
||||
'J.png',
|
||||
'K.png',
|
||||
'Q.png',
|
||||
],
|
||||
Spades:[
|
||||
'2.png',
|
||||
'3.png',
|
||||
'4.png',
|
||||
'5.png',
|
||||
'6.png',
|
||||
'7.png',
|
||||
'8.png',
|
||||
'9.png',
|
||||
'10.png',
|
||||
'A.png',
|
||||
'J.png',
|
||||
'K.png',
|
||||
'Q.png',
|
||||
]
|
||||
}
|
||||
|
||||
let currentDeck = Deck;
|
||||
|
||||
function cardsleft(){
|
||||
return currentDeck.Clubs.length// + currentDeck.Diamonds.length + currentDeck.Hearts.length + currentDeck.Spades.length;
|
||||
}
|
||||
|
||||
function cardAvail(num){
|
||||
console.log(num);
|
||||
console.warn(currentDeck.Clubs);
|
||||
|
||||
let card = Math.floor(Math.random() * num);
|
||||
|
||||
document.getElementById('card').src = `./Clubs/${currentDeck.Clubs[card]}`;
|
||||
|
||||
const index = currentDeck.Clubs.indexOf(currentDeck.Clubs[card]);
|
||||
if(index > -1){ // only splice array when item is found
|
||||
currentDeck.Clubs.splice(index, 1); // Remove one item at the found index
|
||||
console.log('Card removed');
|
||||
}
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
function addCard(){
|
||||
cardAvail(cardsleft());
|
||||
}
|
||||
|
||||
function hit(){
|
||||
addCard();
|
||||
}
|
||||
37
style.css
Normal file
@@ -0,0 +1,37 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap');
|
||||
*{
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: 'Ubuntu', sans-serif;
|
||||
}
|
||||
body{
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
|
||||
min-height: 100vh;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
img.card{
|
||||
aspect-ratio: 1/1;
|
||||
object-fit: contain;
|
||||
height: 200px;
|
||||
margin: .2rem;
|
||||
}
|
||||
|
||||
h2{
|
||||
margin-top: .5rem;
|
||||
}
|
||||
|
||||
button{
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
height: 30px;
|
||||
width: 60px;
|
||||
margin: .5rem;
|
||||
}
|
||||