diff --git a/.github/workflows/pr_close_greet.yml b/.github/workflows/pr_close_greet.yml index 814e727cf7..f06f16ee50 100644 --- a/.github/workflows/pr_close_greet.yml +++ b/.github/workflows/pr_close_greet.yml @@ -19,4 +19,4 @@ jobs: const commentBody = `Thank you @${commentAuthor} , for your valuable time and contribution in our GameZone 💗. \n It’s our GameZone, so Let’s build this GameZone altogether !!🤝\n Hoping to see you soon with another PR again 😇 \n Wishing you all the best for your journey into Open Source🚀 `; await github.issues.createComment({ owner, repo, issue_number: number, body: commentBody }); - console.log(`Commented on the closed PR: ${commentBody}.`); + console.log(`Commented on the closed PR: ${commentBody}.`); \ No newline at end of file diff --git a/Games/Black_jackk/README.md b/Games/Black_jackk/README.md new file mode 100644 index 0000000000..d6ed4acad4 --- /dev/null +++ b/Games/Black_jackk/README.md @@ -0,0 +1,41 @@ + + +Welcome to the Blackjack Game! This is a command-line based implementation of the classic casino game Blackjack, also known as 21. The objective of the game is to beat the dealer by having a hand value closer to 21 without exceeding it. + + +## Screenshot +![alt text]() + +Rules: +Card Values: Number cards (2-10) are worth their face value, face cards (Jack, Queen, King) are worth 10, and Aces can be worth 1 or 11. + +Objective: Beat the dealer by having a hand value closer to 21 without exceeding 21. + +Gameplay: +Both the player and the dealer are dealt two cards initially. + +The player’s cards are both face up, while the dealer has one card face up and one card face down. + +The player can choose to "Hit" (take another card) or "Stand" (end their turn). + +If the player’s hand exceeds 21, they "bust" and lose the game. + +After the player stands, the dealer reveals their face-down card and hits until their hand is 17 or higher. + +If the dealer busts, the player wins. If neither busts, the hand closer to 21 wins. + + +Gameplay: +Starting the Game: + +Run the game script. +The initial hand is dealt, and the current hand values are displayed. +Player's Turn: + +Choose to "Hit" to take another card or "Stand" to end your turn. +Dealer's Turn: + +The dealer reveals their hidden card and draws until their hand value is 17 or higher. +Outcome: + +The result of the game is displayed (Win, Lose, or Draw), and you are prompted to play again. \ No newline at end of file diff --git a/Games/Black_jackk/Screenshot 2024-05-21 165650.png b/Games/Black_jackk/Screenshot 2024-05-21 165650.png new file mode 100644 index 0000000000..83f93f7307 Binary files /dev/null and b/Games/Black_jackk/Screenshot 2024-05-21 165650.png differ diff --git a/Games/Black_jackk/assets/10-C.png b/Games/Black_jackk/assets/10-C.png new file mode 100644 index 0000000000..18af741dbd Binary files /dev/null and b/Games/Black_jackk/assets/10-C.png differ diff --git a/Games/Black_jackk/assets/10-D.png b/Games/Black_jackk/assets/10-D.png new file mode 100644 index 0000000000..3bbc4e06bc Binary files /dev/null and b/Games/Black_jackk/assets/10-D.png differ diff --git a/Games/Black_jackk/assets/10-H.png b/Games/Black_jackk/assets/10-H.png new file mode 100644 index 0000000000..3eb83d72c8 Binary files /dev/null and b/Games/Black_jackk/assets/10-H.png differ diff --git a/Games/Black_jackk/assets/10-S.png b/Games/Black_jackk/assets/10-S.png new file mode 100644 index 0000000000..0b3d29475d Binary files /dev/null and b/Games/Black_jackk/assets/10-S.png differ diff --git a/Games/Black_jackk/assets/2-C.png b/Games/Black_jackk/assets/2-C.png new file mode 100644 index 0000000000..291ed975f2 Binary files /dev/null and b/Games/Black_jackk/assets/2-C.png differ diff --git a/Games/Black_jackk/assets/2-D.png b/Games/Black_jackk/assets/2-D.png new file mode 100644 index 0000000000..4deee7cc84 Binary files /dev/null and b/Games/Black_jackk/assets/2-D.png differ diff --git a/Games/Black_jackk/assets/2-H.png b/Games/Black_jackk/assets/2-H.png new file mode 100644 index 0000000000..75a014f364 Binary files /dev/null and b/Games/Black_jackk/assets/2-H.png differ diff --git a/Games/Black_jackk/assets/2-S.png b/Games/Black_jackk/assets/2-S.png new file mode 100644 index 0000000000..1ce0ffe8b8 Binary files /dev/null and b/Games/Black_jackk/assets/2-S.png differ diff --git a/Games/Black_jackk/assets/3-C.png b/Games/Black_jackk/assets/3-C.png new file mode 100644 index 0000000000..076ab318aa Binary files /dev/null and b/Games/Black_jackk/assets/3-C.png differ diff --git a/Games/Black_jackk/assets/3-D.png b/Games/Black_jackk/assets/3-D.png new file mode 100644 index 0000000000..8ee0b4b902 Binary files /dev/null and b/Games/Black_jackk/assets/3-D.png differ diff --git a/Games/Black_jackk/assets/3-H.png b/Games/Black_jackk/assets/3-H.png new file mode 100644 index 0000000000..8e74673f82 Binary files /dev/null and b/Games/Black_jackk/assets/3-H.png differ diff --git a/Games/Black_jackk/assets/3-S.png b/Games/Black_jackk/assets/3-S.png new file mode 100644 index 0000000000..f9e06b4f01 Binary files /dev/null and b/Games/Black_jackk/assets/3-S.png differ diff --git a/Games/Black_jackk/assets/4-C.png b/Games/Black_jackk/assets/4-C.png new file mode 100644 index 0000000000..8be9e08922 Binary files /dev/null and b/Games/Black_jackk/assets/4-C.png differ diff --git a/Games/Black_jackk/assets/4-D.png b/Games/Black_jackk/assets/4-D.png new file mode 100644 index 0000000000..70e82e839b Binary files /dev/null and b/Games/Black_jackk/assets/4-D.png differ diff --git a/Games/Black_jackk/assets/4-H.png b/Games/Black_jackk/assets/4-H.png new file mode 100644 index 0000000000..ceecbfe02f Binary files /dev/null and b/Games/Black_jackk/assets/4-H.png differ diff --git a/Games/Black_jackk/assets/4-S.png b/Games/Black_jackk/assets/4-S.png new file mode 100644 index 0000000000..95abe3e737 Binary files /dev/null and b/Games/Black_jackk/assets/4-S.png differ diff --git a/Games/Black_jackk/assets/5-C.png b/Games/Black_jackk/assets/5-C.png new file mode 100644 index 0000000000..bde9777696 Binary files /dev/null and b/Games/Black_jackk/assets/5-C.png differ diff --git a/Games/Black_jackk/assets/5-D.png b/Games/Black_jackk/assets/5-D.png new file mode 100644 index 0000000000..bb9252558a Binary files /dev/null and b/Games/Black_jackk/assets/5-D.png differ diff --git a/Games/Black_jackk/assets/5-H.png b/Games/Black_jackk/assets/5-H.png new file mode 100644 index 0000000000..d923456fe8 Binary files /dev/null and b/Games/Black_jackk/assets/5-H.png differ diff --git a/Games/Black_jackk/assets/5-S.png b/Games/Black_jackk/assets/5-S.png new file mode 100644 index 0000000000..53a1aad26c Binary files /dev/null and b/Games/Black_jackk/assets/5-S.png differ diff --git a/Games/Black_jackk/assets/6-C.png b/Games/Black_jackk/assets/6-C.png new file mode 100644 index 0000000000..a9660a0372 Binary files /dev/null and b/Games/Black_jackk/assets/6-C.png differ diff --git a/Games/Black_jackk/assets/6-D.png b/Games/Black_jackk/assets/6-D.png new file mode 100644 index 0000000000..78a80ad06a Binary files /dev/null and b/Games/Black_jackk/assets/6-D.png differ diff --git a/Games/Black_jackk/assets/6-H.png b/Games/Black_jackk/assets/6-H.png new file mode 100644 index 0000000000..361643efc3 Binary files /dev/null and b/Games/Black_jackk/assets/6-H.png differ diff --git a/Games/Black_jackk/assets/6-S.png b/Games/Black_jackk/assets/6-S.png new file mode 100644 index 0000000000..40242a718b Binary files /dev/null and b/Games/Black_jackk/assets/6-S.png differ diff --git a/Games/Black_jackk/assets/7-C.png b/Games/Black_jackk/assets/7-C.png new file mode 100644 index 0000000000..9d6b54554f Binary files /dev/null and b/Games/Black_jackk/assets/7-C.png differ diff --git a/Games/Black_jackk/assets/7-D.png b/Games/Black_jackk/assets/7-D.png new file mode 100644 index 0000000000..6ad5f15b51 Binary files /dev/null and b/Games/Black_jackk/assets/7-D.png differ diff --git a/Games/Black_jackk/assets/7-H.png b/Games/Black_jackk/assets/7-H.png new file mode 100644 index 0000000000..19b89a2e7e Binary files /dev/null and b/Games/Black_jackk/assets/7-H.png differ diff --git a/Games/Black_jackk/assets/7-S.png b/Games/Black_jackk/assets/7-S.png new file mode 100644 index 0000000000..b9f1b93d33 Binary files /dev/null and b/Games/Black_jackk/assets/7-S.png differ diff --git a/Games/Black_jackk/assets/8-C.png b/Games/Black_jackk/assets/8-C.png new file mode 100644 index 0000000000..cec743cbcd Binary files /dev/null and b/Games/Black_jackk/assets/8-C.png differ diff --git a/Games/Black_jackk/assets/8-D.png b/Games/Black_jackk/assets/8-D.png new file mode 100644 index 0000000000..ed1295121d Binary files /dev/null and b/Games/Black_jackk/assets/8-D.png differ diff --git a/Games/Black_jackk/assets/8-H.png b/Games/Black_jackk/assets/8-H.png new file mode 100644 index 0000000000..fb39723cb1 Binary files /dev/null and b/Games/Black_jackk/assets/8-H.png differ diff --git a/Games/Black_jackk/assets/8-S.png b/Games/Black_jackk/assets/8-S.png new file mode 100644 index 0000000000..b6b3b3813d Binary files /dev/null and b/Games/Black_jackk/assets/8-S.png differ diff --git a/Games/Black_jackk/assets/9-C.png b/Games/Black_jackk/assets/9-C.png new file mode 100644 index 0000000000..2174db58e1 Binary files /dev/null and b/Games/Black_jackk/assets/9-C.png differ diff --git a/Games/Black_jackk/assets/9-D.png b/Games/Black_jackk/assets/9-D.png new file mode 100644 index 0000000000..0b933fb0e6 Binary files /dev/null and b/Games/Black_jackk/assets/9-D.png differ diff --git a/Games/Black_jackk/assets/9-H.png b/Games/Black_jackk/assets/9-H.png new file mode 100644 index 0000000000..7b196d6dc0 Binary files /dev/null and b/Games/Black_jackk/assets/9-H.png differ diff --git a/Games/Black_jackk/assets/9-S.png b/Games/Black_jackk/assets/9-S.png new file mode 100644 index 0000000000..3c3b5ffbc6 Binary files /dev/null and b/Games/Black_jackk/assets/9-S.png differ diff --git a/Games/Black_jackk/assets/A-C.png b/Games/Black_jackk/assets/A-C.png new file mode 100644 index 0000000000..42bf5ec94d Binary files /dev/null and b/Games/Black_jackk/assets/A-C.png differ diff --git a/Games/Black_jackk/assets/A-D.png b/Games/Black_jackk/assets/A-D.png new file mode 100644 index 0000000000..79cd3b8a80 Binary files /dev/null and b/Games/Black_jackk/assets/A-D.png differ diff --git a/Games/Black_jackk/assets/A-H.png b/Games/Black_jackk/assets/A-H.png new file mode 100644 index 0000000000..b42212405c Binary files /dev/null and b/Games/Black_jackk/assets/A-H.png differ diff --git a/Games/Black_jackk/assets/A-S.png b/Games/Black_jackk/assets/A-S.png new file mode 100644 index 0000000000..103f56d1a8 Binary files /dev/null and b/Games/Black_jackk/assets/A-S.png differ diff --git a/Games/Black_jackk/assets/BACK.png b/Games/Black_jackk/assets/BACK.png new file mode 100644 index 0000000000..2e02e052c9 Binary files /dev/null and b/Games/Black_jackk/assets/BACK.png differ diff --git a/Games/Black_jackk/assets/J-B.png b/Games/Black_jackk/assets/J-B.png new file mode 100644 index 0000000000..000b640bff Binary files /dev/null and b/Games/Black_jackk/assets/J-B.png differ diff --git a/Games/Black_jackk/assets/J-C.png b/Games/Black_jackk/assets/J-C.png new file mode 100644 index 0000000000..5e003be2d4 Binary files /dev/null and b/Games/Black_jackk/assets/J-C.png differ diff --git a/Games/Black_jackk/assets/J-D.png b/Games/Black_jackk/assets/J-D.png new file mode 100644 index 0000000000..131a97731b Binary files /dev/null and b/Games/Black_jackk/assets/J-D.png differ diff --git a/Games/Black_jackk/assets/J-H.png b/Games/Black_jackk/assets/J-H.png new file mode 100644 index 0000000000..bf342bcb29 Binary files /dev/null and b/Games/Black_jackk/assets/J-H.png differ diff --git a/Games/Black_jackk/assets/J-R.png b/Games/Black_jackk/assets/J-R.png new file mode 100644 index 0000000000..55b3ef9ba5 Binary files /dev/null and b/Games/Black_jackk/assets/J-R.png differ diff --git a/Games/Black_jackk/assets/J-S.png b/Games/Black_jackk/assets/J-S.png new file mode 100644 index 0000000000..f539c19c6c Binary files /dev/null and b/Games/Black_jackk/assets/J-S.png differ diff --git a/Games/Black_jackk/assets/K-C.png b/Games/Black_jackk/assets/K-C.png new file mode 100644 index 0000000000..68e57747d7 Binary files /dev/null and b/Games/Black_jackk/assets/K-C.png differ diff --git a/Games/Black_jackk/assets/K-D.png b/Games/Black_jackk/assets/K-D.png new file mode 100644 index 0000000000..e21d6a0a4a Binary files /dev/null and b/Games/Black_jackk/assets/K-D.png differ diff --git a/Games/Black_jackk/assets/K-H.png b/Games/Black_jackk/assets/K-H.png new file mode 100644 index 0000000000..1d3c468d8e Binary files /dev/null and b/Games/Black_jackk/assets/K-H.png differ diff --git a/Games/Black_jackk/assets/K-S.png b/Games/Black_jackk/assets/K-S.png new file mode 100644 index 0000000000..2edbbc1484 Binary files /dev/null and b/Games/Black_jackk/assets/K-S.png differ diff --git a/Games/Black_jackk/assets/Q-C.png b/Games/Black_jackk/assets/Q-C.png new file mode 100644 index 0000000000..7be5f9a96a Binary files /dev/null and b/Games/Black_jackk/assets/Q-C.png differ diff --git a/Games/Black_jackk/assets/Q-D.png b/Games/Black_jackk/assets/Q-D.png new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Games/Black_jackk/assets/Q-H.png b/Games/Black_jackk/assets/Q-H.png new file mode 100644 index 0000000000..21839e681a Binary files /dev/null and b/Games/Black_jackk/assets/Q-H.png differ diff --git a/Games/Black_jackk/assets/Q-S.png b/Games/Black_jackk/assets/Q-S.png new file mode 100644 index 0000000000..7983d034dd Binary files /dev/null and b/Games/Black_jackk/assets/Q-S.png differ diff --git a/Games/Black_jackk/assets/Screenshot 2024-05-21 165650.png b/Games/Black_jackk/assets/Screenshot 2024-05-21 165650.png new file mode 100644 index 0000000000..83f93f7307 Binary files /dev/null and b/Games/Black_jackk/assets/Screenshot 2024-05-21 165650.png differ diff --git a/Games/Black_jackk/assets/blackjack.jpg b/Games/Black_jackk/assets/blackjack.jpg new file mode 100644 index 0000000000..6ac3ac7726 Binary files /dev/null and b/Games/Black_jackk/assets/blackjack.jpg differ diff --git a/Games/Black_jackk/index.html b/Games/Black_jackk/index.html new file mode 100644 index 0000000000..33a7bd45b4 --- /dev/null +++ b/Games/Black_jackk/index.html @@ -0,0 +1,27 @@ + + + + + + Black Jack + + + + + +

Dealer:

+
+ +
+ +

You:

+
+ +
+ + +

+ + + + \ No newline at end of file diff --git a/Games/Black_jackk/script.js b/Games/Black_jackk/script.js new file mode 100644 index 0000000000..17b0d5cf48 --- /dev/null +++ b/Games/Black_jackk/script.js @@ -0,0 +1,148 @@ + +let dealerSum = 0; +let yourSum = 0; + +let dealerAceCount = 0; +let yourAceCount = 0; + +let hidden; +let deck; + +let canHit = true; //allows the player (you) to draw while yourSum <= 21 + +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]); //A-C -> K-C, A-D -> K-D + } + } + // console.log(deck); +} + +function shuffleDeck() { + for (let i = 0; i < deck.length; i++) { + let j = Math.floor(Math.random() * deck.length); // (0-1) * 52 => (0-51.9999) + 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) { + // + let cardImg = document.createElement("img"); + let card = deck.pop(); + cardImg.src = "./assets/" + 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 = "./assets/" + 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 = "./assets/" + card + ".png"; + yourSum += getValue(card); + yourAceCount += checkAce(card); + document.getElementById("your-cards").append(cardImg); + + if (reduceAce(yourSum, yourAceCount) > 21) { //A, J, 8 -> 1 + 10 + 8 + canHit = false; + } + +} + +function stay() { + dealerSum = reduceAce(dealerSum, dealerAceCount); + yourSum = reduceAce(yourSum, yourAceCount); + + canHit = false; + document.getElementById("hidden").src = "./assets/" + hidden + ".png"; + + let message = ""; + if (yourSum > 21) { + message = "You Lose!"; + } + else if (dealerSum > 21) { + message = "You win!"; + } + //both you and dealer <= 21 + else if (yourSum == dealerSum) { + message = "Tie!"; + } + else if (yourSum > dealerSum) { + message = "You Win!"; + } + else if (yourSum < dealerSum) { + message = "You Lose!"; + } + + 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; +} \ No newline at end of file diff --git a/Games/Black_jackk/style.css b/Games/Black_jackk/style.css new file mode 100644 index 0000000000..8ea2ebb9c7 --- /dev/null +++ b/Games/Black_jackk/style.css @@ -0,0 +1,28 @@ +body { + font-family: Arial, Helvetica, sans-serif; + text-align: center; +} + +#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; +} \ No newline at end of file diff --git a/README.md b/README.md index 4b7aca26d5..5ff3a268e5 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,7 @@ This repository also provides one such platforms where contributers come over an | 166 | [Shpere](https://github.com/kunjgit/GameZone/tree/main/Games/Shpere)| | 167 | [Short Circuit](https://github.com/kunjgit/GameZone/tree/main/Games/Short%20Circuit)| | 168 | [Dot Connect](https://github.com/kunjgit/GameZone/tree/main/Games/Dot_Connect)| +| * | [Black_jackk](https://github.com/kunjgit/GameZone/tree/main/Games/Black_jackk)| | Game | Game | Game | Game | Game | @@ -396,7 +397,6 @@ This repository also provides one such platforms where contributers come over an | [Rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/Rock_paper_scissor) | | [City_Builder_Game](https://github.com/kunjgit/GameZone/tree/main/Games/City_Builder_Game) | - main @@ -462,4 +462,4 @@ Terms and conditions for use, reproduction and distribution are under the [Apach
-

Back to top

\ No newline at end of file +

Back to top

diff --git a/assets/images/Black_jackk.jpg b/assets/images/Black_jackk.jpg new file mode 100644 index 0000000000..6ac3ac7726 Binary files /dev/null and b/assets/images/Black_jackk.jpg differ diff --git a/assets/index_old.html b/assets/index_old.html index 9a98c8b0d3..ab72d1e1ff 100644 --- a/assets/index_old.html +++ b/assets/index_old.html @@ -2686,6 +2686,7 @@

Play and have fun!

+
  • @@ -2707,7 +2708,6 @@

  • - diff --git a/assets/js/gamesData.json b/assets/js/gamesData.json index 6ebb9c244a..2ecd456cfd 100644 --- a/assets/js/gamesData.json +++ b/assets/js/gamesData.json @@ -1969,8 +1969,11 @@ "gameUrl": "Dice_Roller", "thumbnailUrl": "Dice_Roller.png" }, -"392":{ + "392":{ "gameTitle": "Dot Connect", "gameUrl": "Dot_Connect", "thumbnailUrl": "Dot_Connect.png" -} + }, + + +