Browse Source

update slots et bj

master
clochard.l 3 years ago
parent
commit
4194dac457
  1. 74
      BJ.html
  2. 2
      Index.html
  3. BIN
      J-B.png
  4. BIN
      J-C.png
  5. BIN
      J-D.png
  6. BIN
      J-H.png
  7. BIN
      J-R.png
  8. BIN
      J-S.png
  9. BIN
      K-C.png
  10. BIN
      K-D.png
  11. BIN
      K-H.png
  12. BIN
      K-S.png
  13. BIN
      Q-C.png
  14. BIN
      Q-D.png
  15. BIN
      Q-H.png
  16. BIN
      Q-S.png
  17. 151
      bj.js
  18. BIN
      cards/10-C.png
  19. BIN
      cards/10-D.png
  20. BIN
      cards/10-H.png
  21. BIN
      cards/10-S.png
  22. BIN
      cards/2-C.png
  23. BIN
      cards/2-D.png
  24. BIN
      cards/2-H.png
  25. BIN
      cards/2-S.png
  26. BIN
      cards/3-C.png
  27. BIN
      cards/3-D.png
  28. BIN
      cards/3-H.png
  29. BIN
      cards/3-S.png
  30. BIN
      cards/4-C.png
  31. BIN
      cards/4-D.png
  32. BIN
      cards/4-H.png
  33. BIN
      cards/4-S.png
  34. BIN
      cards/5-C.png
  35. BIN
      cards/5-D.png
  36. BIN
      cards/5-H.png
  37. BIN
      cards/5-S.png
  38. BIN
      cards/6-C.png
  39. BIN
      cards/6-D.png
  40. BIN
      cards/6-H.png
  41. BIN
      cards/6-S.png
  42. BIN
      cards/7-C.png
  43. BIN
      cards/7-D.png
  44. BIN
      cards/7-H.png
  45. BIN
      cards/7-S.png
  46. BIN
      cards/8-C.png
  47. BIN
      cards/8-D.png
  48. BIN
      cards/8-H.png
  49. BIN
      cards/8-S.png
  50. BIN
      cards/9-C.png
  51. BIN
      cards/9-D.png
  52. BIN
      cards/9-H.png
  53. BIN
      cards/9-S.png
  54. BIN
      cards/A-C.png
  55. BIN
      cards/A-D.png
  56. BIN
      cards/A-H.png
  57. BIN
      cards/A-S.png
  58. BIN
      cards/BACK.png
  59. BIN
      cards/J-B.png
  60. BIN
      cards/J-C.png
  61. BIN
      cards/J-D.png
  62. BIN
      cards/J-H.png
  63. BIN
      cards/J-R.png
  64. BIN
      cards/J-S.png
  65. BIN
      cards/K-C.png
  66. BIN
      cards/K-D.png
  67. BIN
      cards/K-H.png
  68. BIN
      cards/K-S.png
  69. BIN
      cards/Q-C.png
  70. BIN
      cards/Q-D.png
  71. BIN
      cards/Q-H.png
  72. BIN
      cards/Q-S.png
  73. 76
      styles.css

74
BJ.html

@ -0,0 +1,74 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>casino 77</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<img class=logo src="image/logo.png">
<a href="Index.html">
<img class=accueil src="image/accueil.png">
</a>
<div class="loader">
<span class="lettre">7</span>
<span class="lettre">7</span>
<span class="lettre">7</span>
</div>
<h2 class="h2bj">BLACK JACK</h2>
<div class="bjform">
<h3>Dealer: <span id="dealer-sum"></span></h3>
<div id="dealer-cards">
<img id="hidden" src="./cards/BACK.png">
</div>
<h3>You: <span id="your-sum"></span></h3>
<div id="your-cards"></div>
<br>
<div class="buttonhs">
<button id="hit">Hit</button>
<button id="stay">Stay</button>
</div>
<p id="results"></p>
</div>
<div class="reload">
<input type="button" onclick='window.location.reload(false)' value="Rafraichir" />
</div>
<div class="bg"></div>
<script src="loading.js"></script>
<script src="bj.js"></script>
</body>
</html>

2
Index.html

@ -32,7 +32,9 @@
<a href="slots.html"> <a href="slots.html">
<img class="img1" src="image/imgnoirslot.png" onmouseover="this.src='image/bgcasino.jpg';" onmouseout="this.src='image/imgnoirslot.png'" alt="" /> <img class="img1" src="image/imgnoirslot.png" onmouseover="this.src='image/bgcasino.jpg';" onmouseout="this.src='image/imgnoirslot.png'" alt="" />
</a> </a>
<a href="BJ.html">
<img class="img2" src="image/imgnoirbj.png" onmouseover="this.src='image/bgcasino.jpg';" onmouseout="this.src='image/imgnoirbj.png'" alt="" /> <img class="img2" src="image/imgnoirbj.png" onmouseover="this.src='image/bgcasino.jpg';" onmouseout="this.src='image/imgnoirbj.png'" alt="" />
</a>
<img class="img3" src="image/imgnoirroulette.png" onmouseover="this.src='image/bgcasino.jpg';" onmouseout="this.src='image/imgnoirroulette.png'" alt="" /> <img class="img3" src="image/imgnoirroulette.png" onmouseover="this.src='image/bgcasino.jpg';" onmouseout="this.src='image/imgnoirroulette.png'" alt="" />
<img class="img4" src="image/imgnoirbingo.png" onmouseover="this.src='image/bgcasino.jpg';" onmouseout="this.src='image/imgnoirbingo.png'" alt="" /> <img class="img4" src="image/imgnoirbingo.png" onmouseover="this.src='image/bgcasino.jpg';" onmouseout="this.src='image/imgnoirbingo.png'" alt="" />

BIN
J-B.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
J-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

BIN
J-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

BIN
J-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

BIN
J-R.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
J-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

BIN
K-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

BIN
K-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

BIN
K-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

BIN
K-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

BIN
Q-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

BIN
Q-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

BIN
Q-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

BIN
Q-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

151
bj.js

@ -0,0 +1,151 @@
var dealerSum = 0;
var yourSum = 0;
var dealerAceCount = 0;
var yourAceCount = 0;
var hidden;
var deck;
var canHit = true;
window.onload = function() {
buildDeck();
shuffleDeck();
startGame();
}
function buildDeck() {
let values = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"];
let types = ["C", "D", "H", "S"];
deck = [];
for (let i = 0; i < types.length; i++) {
for (let j = 0; j < values.length; j++) {
deck.push(values[j] + "-" + types[i]);
}
}
// console.log(deck);
}
function shuffleDeck() {
for (let i = 0; i < deck.length; i++) {
let j = Math.floor(Math.random() * deck.length);
let temp = deck[i];
deck[i] = deck[j];
deck[j] = temp;
}
console.log(deck);
}
function startGame() {
hidden = deck.pop();
dealerSum += getValue(hidden);
dealerAceCount += checkAce(hidden);
// console.log(hidden);
// console.log(dealerSum);
while (dealerSum < 17) {
//<img src="./cards/4-C.png">
let cardImg = document.createElement("img");
let card = deck.pop();
cardImg.src = "./cards/" + card + ".png";
dealerSum += getValue(card);
dealerAceCount += checkAce(card);
document.getElementById("dealer-cards").append(cardImg);
}
console.log(dealerSum);
for (let i = 0; i < 2; i++) {
let cardImg = document.createElement("img");
let card = deck.pop();
cardImg.src = "./cards/" + card + ".png";
yourSum += getValue(card);
yourAceCount += checkAce(card);
document.getElementById("your-cards").append(cardImg);
}
console.log(yourSum);
document.getElementById("hit").addEventListener("click", hit);
document.getElementById("stay").addEventListener("click", stay);
}
function hit() {
if (!canHit) {
return;
}
let cardImg = document.createElement("img");
let card = deck.pop();
cardImg.src = "./cards/" + card + ".png";
yourSum += getValue(card);
yourAceCount += checkAce(card);
document.getElementById("your-cards").append(cardImg);
if (reduceAce(yourSum, yourAceCount) > 21) {
canHit = false;
}
}
function stay() {
dealerSum = reduceAce(dealerSum, dealerAceCount);
yourSum = reduceAce(yourSum, yourAceCount);
canHit = false;
document.getElementById("hidden").src = "./cards/" + hidden + ".png";
let message = "";
if (yourSum > 21) {
message = "Tu as perdu!";
}
else if (dealerSum > 21) {
message = "Tu as gagné!";
}
//both you and dealer <= 21
else if (yourSum == dealerSum) {
message = "Egalite!";
}
else if (yourSum > dealerSum) {
message = "Tu as gagné!";
}
else if (yourSum < dealerSum) {
message = "Tu as perdu!";
}
document.getElementById("dealer-sum").innerText = dealerSum;
document.getElementById("your-sum").innerText = yourSum;
document.getElementById("results").innerText = message;
}
function getValue(card) {
let data = card.split("-"); // "4-C" -> ["4", "C"]
let value = data[0];
if (isNaN(value)) { //A J Q K
if (value == "A") {
return 11;
}
return 10;
}
return parseInt(value);
}
function checkAce(card) {
if (card[0] == "A") {
return 1;
}
return 0;
}
function reduceAce(playerSum, playerAceCount) {
while (playerSum > 21 && playerAceCount > 0) {
playerSum -= 10;
playerAceCount -= 1;
}
return playerSum;
}
var refresh = window.getElementById('refresh');
refresh.addEventListener('click', location.reload(), false);

BIN
cards/10-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
cards/10-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
cards/10-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
cards/10-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
cards/2-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
cards/2-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
cards/2-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
cards/2-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
cards/3-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
cards/3-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
cards/3-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
cards/3-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
cards/4-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
cards/4-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
cards/4-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
cards/4-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
cards/5-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
cards/5-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
cards/5-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
cards/5-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
cards/6-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
cards/6-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
cards/6-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
cards/6-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
cards/7-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
cards/7-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
cards/7-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
cards/7-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
cards/8-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
cards/8-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
cards/8-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
cards/8-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
cards/9-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
cards/9-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
cards/9-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
cards/9-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
cards/A-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
cards/A-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
cards/A-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
cards/A-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
cards/BACK.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 KiB

BIN
cards/J-B.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
cards/J-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

BIN
cards/J-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

BIN
cards/J-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

BIN
cards/J-R.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
cards/J-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

BIN
cards/K-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

BIN
cards/K-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

BIN
cards/K-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

BIN
cards/K-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

BIN
cards/Q-C.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

BIN
cards/Q-D.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

BIN
cards/Q-H.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

BIN
cards/Q-S.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

76
styles.css

@ -225,7 +225,7 @@
.bg { .bg {
width: 100%; width: 100%;
opacity; 50%; opacity; 50%;
height: 200vh; height: 100vh;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -269,11 +269,12 @@
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
margin-top: 15%;
} }
.doors { .doors {
/*display: flex;*/ /*display: flex;*/
} }
.bank{ .bank{
@ -344,7 +345,7 @@ button {
body{ body{
color: rgb(137,46,255); color: rgb(90,46,255);
font-family: "casino"; font-family: "casino";
text-shadow: 0 0 7px rgb(147,112,219), text-shadow: 0 0 7px rgb(147,112,219),
0 0 25px rgb(147,112,219), 0 0 25px rgb(147,112,219),
@ -356,7 +357,7 @@ body{
} }
h1{ h1{
color: rgb(137,46,255); color: rgb(190,46,255);
text-shadow: 0 0 7px rgb(147,112,219), text-shadow: 0 0 7px rgb(147,112,219),
0 0 10px rgb(147,112,219), 0 0 10px rgb(147,112,219),
0 0 25px rgb(147,112,219), 0 0 25px rgb(147,112,219),
@ -367,8 +368,8 @@ h1{
.slot { .slot {
position: absolute; position: absolute;
z-index: 1; z-index: 1;
margin-top: 35%; margin-top: 18%;
margin-left: 38%; margin-left: 39%;
} }
@ -376,9 +377,9 @@ h1{
h2{ h2{
position: absolute; position: absolute;
z-index: 1; z-index: 1;
font-size: 300%; font-size: 200%;
margin-top: 20%; margin-top: 15%;
margin-left: 44%; margin-left: 46%;
color: rgb(90,46,255); color: rgb(90,46,255);
text-shadow: 0 0 7px rgb(0,0,219), text-shadow: 0 0 7px rgb(0,0,219),
@ -387,14 +388,71 @@ h2{
0 0 35px rgb(147,112,219), 0 0 35px rgb(147,112,219),
0 0 45px rgb(147,112,219) 0 0 45px rgb(147,112,219)
} }
#dealer-cards img {
height: 175px;
width: 125px;
margin: 1px;
}
#your-cards img {
height: 175px;
width: 125px;
margin: 1px;
}
#hit {
width: 100px;
height: 50px;
font-size: 20px;
} }
#stay {
width: 100px;
height: 50px;
font-size: 20px;
}
.buttonhs {
position: fixed;
margin-left: 5%;
margin-top: 2%;
}
.bjform {
position: absolute;
z-index: 1;
margin-top: 21%;
margin-left: 38%;
}
.h2bj {
position: absolute;
z-index: 1;
font-size: 200%;
margin-top: 15%;
margin-left: 43%;
color: rgb(90,46,255);
text-shadow: 0 0 7px rgb(0,0,219),
0 0 10px rgb(147,112,219),
0 0 25px rgb(147,112,219),
0 0 35px rgb(147,112,219),
0 0 45px rgb(147,112,219)
}
.reload {
position: absolute;
z-index: 1;
margin-top: 49%;
margin-left: 47%;
}

Loading…
Cancel
Save