diff --git a/Games/Taash Game/README.md b/Games/Taash Game/README.md new file mode 100644 index 0000000000..747d250379 --- /dev/null +++ b/Games/Taash Game/README.md @@ -0,0 +1,12 @@ +# Taash Game +The player has to get a hand with a value as close to 21 as possible without going over. +A hand that goes over 21 is a bust. +The players in a Taash Game plays against the dealer. Each player has to beat the dealer's hand in order to win. + +In Taash Game, the suits have no meaning. +1. Number cards have a value equal to their number. +2. All the picture cards (Jacks, Queens, and Kings) are worth 10. +3. Aces are worth 1. +4. The table keeps a record of total wins,loses and draws +5. Click on "Restart" Button to start a new game +6. Click on "Deal" Button to clear the field diff --git a/Games/Taash Game/images/10.png b/Games/Taash Game/images/10.png new file mode 100644 index 0000000000..01be5daa37 Binary files /dev/null and b/Games/Taash Game/images/10.png differ diff --git a/Games/Taash Game/images/2.png b/Games/Taash Game/images/2.png new file mode 100644 index 0000000000..2f1d24063f Binary files /dev/null and b/Games/Taash Game/images/2.png differ diff --git a/Games/Taash Game/images/3.png b/Games/Taash Game/images/3.png new file mode 100644 index 0000000000..7c804ae15b Binary files /dev/null and b/Games/Taash Game/images/3.png differ diff --git a/Games/Taash Game/images/4.png b/Games/Taash Game/images/4.png new file mode 100644 index 0000000000..ea50674261 Binary files /dev/null and b/Games/Taash Game/images/4.png differ diff --git a/Games/Taash Game/images/5.png b/Games/Taash Game/images/5.png new file mode 100644 index 0000000000..f456f1e71d Binary files /dev/null and b/Games/Taash Game/images/5.png differ diff --git a/Games/Taash Game/images/6.png b/Games/Taash Game/images/6.png new file mode 100644 index 0000000000..46b86bcc59 Binary files /dev/null and b/Games/Taash Game/images/6.png differ diff --git a/Games/Taash Game/images/7.png b/Games/Taash Game/images/7.png new file mode 100644 index 0000000000..1a21883717 Binary files /dev/null and b/Games/Taash Game/images/7.png differ diff --git a/Games/Taash Game/images/8.png b/Games/Taash Game/images/8.png new file mode 100644 index 0000000000..277705b131 Binary files /dev/null and b/Games/Taash Game/images/8.png differ diff --git a/Games/Taash Game/images/9.png b/Games/Taash Game/images/9.png new file mode 100644 index 0000000000..b3fdc074b0 Binary files /dev/null and b/Games/Taash Game/images/9.png differ diff --git a/Games/Taash Game/images/A.png b/Games/Taash Game/images/A.png new file mode 100644 index 0000000000..bb25fee819 Binary files /dev/null and b/Games/Taash Game/images/A.png differ diff --git a/Games/Taash Game/images/J.png b/Games/Taash Game/images/J.png new file mode 100644 index 0000000000..7960a94e7a Binary files /dev/null and b/Games/Taash Game/images/J.png differ diff --git a/Games/Taash Game/images/K.png b/Games/Taash Game/images/K.png new file mode 100644 index 0000000000..c9d1c990ea Binary files /dev/null and b/Games/Taash Game/images/K.png differ diff --git a/Games/Taash Game/images/Q.png b/Games/Taash Game/images/Q.png new file mode 100644 index 0000000000..6499247e29 Binary files /dev/null and b/Games/Taash Game/images/Q.png differ diff --git a/Games/Taash Game/index.html b/Games/Taash Game/index.html new file mode 100644 index 0000000000..2d05937546 --- /dev/null +++ b/Games/Taash Game/index.html @@ -0,0 +1,62 @@ + + + + + Taash Game + + + + + +
+

Taash Game

+

Let's Play

+ +
+
+

You: 0

+
+ +
+

Dealer: 0

+
+
+ +
+
+ + + + +
+
+
+ + + + + + + + + + + + +
WinLoseDraw
000
+
+
+ + + diff --git a/Games/Taash Game/script.js b/Games/Taash Game/script.js new file mode 100644 index 0000000000..b38f56eeed --- /dev/null +++ b/Games/Taash Game/script.js @@ -0,0 +1,250 @@ +let blackjackGame = { + you: { + scoreSpan: "#your-blackjack-result", + div: "#your-box", + boxSize: ".flex-blackjack-row-2 div", + score: 0, + }, + + dealer: { + scoreSpan: "#dealer-blackjack-result", + div: "#dealer-box", + boxSize: ".flex-blackjack-row-2 div", + score: 0, + }, + + cards: ["2", "3", "4", "5", "6", "7", "8", "9", "10", "K", "J", "Q", "A"], + + cardsMap: { + 2: 2, + 3: 3, + 4: 4, + 5: 5, + 6: 6, + 7: 7, + 8: 8, + 9: 9, + 10: 10, + K: 10, + J: 10, + Q: 10, + A: [1, 11], + }, + + wins: 0, + losses: 0, + draws: 0, + isStand: false, + isTurnsOver: false, + pressOnce: false, +}; + +const YOU = blackjackGame["you"]; +const DEALER = blackjackGame["dealer"]; + +const hitSound = new Audio("sounds/swish.m4a"); +const winSound = new Audio("sounds/cash.mp3"); +const loseSound = new Audio("sounds/aww.mp3"); + +let windowWidth = window.screen.width; +let windowHeight = window.screen.height; +let winner; + +//Button Event Listeners +document + .querySelector("#blackjack-hit-button") + .addEventListener("click", blackjackHit); +document + .querySelector("#blackjack-stand-button") + .addEventListener("click", blackjackStand); +document + .querySelector("#blackjack-deal-button") + .addEventListener("click", blackjackDeal); +document + .querySelector("#blackjack-reset-button") + .addEventListener("click", blackjackRestart); + +function blackjackHit() { + if (blackjackGame["isStand"] === false) { + let card = randomCard(); + showCard(card, YOU); + updateScore(card, YOU); + showScore(YOU); + } +} + +function randomCard() { + let randomIndex = Math.floor(Math.random() * 13); + return blackjackGame["cards"][randomIndex]; +} + +function showCard(card, activePlayer) { + if (activePlayer["score"] <= 21) { + let cardImage = document.createElement("img"); + cardImage.src = `images/${card}.png`; + cardImage.style = `width:${widthSize()}; height:${heightSize()};`; + document.querySelector(activePlayer["div"]).appendChild(cardImage); + hitSound.play(); + } +} + +function widthSize() { + if (windowWidth > 1000) { + let newWidthSize = window.screen.width * 0.1; + return newWidthSize; + } else { + return window.screen.width * 0.18; + } +} + +function heightSize() { + if (windowHeight > 700) { + let newHeightSize = window.screen.height * 0.18; + return newHeightSize; + } else { + return window.screen.height * 0.15; + } +} + +function updateScore(card, activePlayer) { + if (card === "A") { + if (activePlayer["score"] + blackjackGame["cardsMap"][card][1] <= 21) { + activePlayer["score"] += blackjackGame["cardsMap"][card][1]; + } else { + activePlayer["score"] += blackjackGame["cardsMap"][card][0]; + } + } else { + activePlayer["score"] += blackjackGame["cardsMap"][card]; + } + + console.log(activePlayer["score"]); +} + +function showScore(activePlayer) { + //Bust logic if score is over 21 + if (activePlayer["score"] > 21) { + document.querySelector(activePlayer["scoreSpan"]).textContent = "BUST!"; + document.querySelector(activePlayer["scoreSpan"]).style.color = "red"; + } else { + document.querySelector(activePlayer["scoreSpan"]).textContent = + activePlayer["score"]; + } +} + +function blackjackStand() { + if (blackjackGame.pressOnce === false) { + blackjackGame["isStand"] = true; + let yourImages = document + .querySelector("#your-box") + .querySelectorAll("img"); + + for (let i = 0; i < yourImages.length; i++) { + let card = randomCard(); + showCard(card, DEALER); + updateScore(card, DEALER); + showScore(DEALER); + } + + blackjackGame["isTurnsOver"] = true; + + computeWinner(); + showWinner(winner); + } + + blackjackGame.pressOnce = true; +} + +function computeWinner() { + if (YOU["score"] <= 21) { + if (YOU["score"] > DEALER["score"] || DEALER["score"] > 21) { + winner = YOU; + } else if (YOU["score"] < DEALER["score"]) { + winner = DEALER; + } else if (YOU["score"] === DEALER["score"]) { + winner = "Draw"; + } + } else if (YOU["score"] > 21 && DEALER["score"] <= 21) { + winner = DEALER; + } else if (YOU["score"] > 21 && DEALER["score"] > 21) { + winner = "None"; + } + + return winner; +} + +function showWinner(winner) { + let message, messageColor; + + if (winner === YOU) { + message = "You Won"; + messageColor = "#00e676"; + document.querySelector("#wins").textContent = blackjackGame["wins"] += 1; + winSound.play(); + } else if (winner === DEALER) { + message = "You Lost"; + messageColor = "red"; + document.querySelector("#losses").textContent = blackjackGame[ + "losses" + ] += 1; + loseSound.play(); + } else if (winner === "Draw") { + message = "You Drew"; + messageColor = "yellow"; + document.querySelector("#draws").textContent = blackjackGame["draws"] += 1; + loseSound.play(); + } else if (winner === "None") { + message = "You Both Busted!"; + messageColor = "orange"; + loseSound.play(); + } + + document.querySelector("#blackjack-result").textContent = message; + document.querySelector("#blackjack-result").style.color = messageColor; +} + +function blackjackDeal() { + if (blackjackGame["isTurnsOver"] === true) { + // Select all the images in both the user and dealer box + let yourImages = document + .querySelector("#your-box") + .querySelectorAll("img"); + let dealerImages = document + .querySelector("#dealer-box") + .querySelectorAll("img"); + + document.querySelector("#blackjack-result").style.color = "white"; + + //Sets the user and dealers scors to zero + YOU["score"] = DEALER["score"] = 0; + document.querySelector("#your-blackjack-result").textContent = 0; + document.querySelector("#dealer-blackjack-result").textContent = 0; + + //Reset color back to white + document.querySelector("#your-blackjack-result").style.color = "white"; + document.querySelector("#dealer-blackjack-result").style.color = "white"; + + //Reset to Let's Play + document.querySelector("#blackjack-result").textContent = "Lets Play"; + + //Removes the cards in the user's box + for (let i = 0; i < yourImages.length; i++) { + yourImages[i].remove(); + dealerImages[i].remove(); + } + + blackjackGame["isStand"] = false; + blackjackGame.pressOnce = false; + blackjackGame["isTurnsOver"] = false; + } +} + +function blackjackRestart() { + blackjackDeal(); + document.querySelector("#wins").textContent = 0; + document.querySelector("#losses").textContent = 0; + document.querySelector("#draws").textContent = 0; + + blackjackGame.wins = 0; + blackjackGame.losses = 0; + blackjackGame.draws = 0; +} diff --git a/Games/Taash Game/sounds/aww.mp3 b/Games/Taash Game/sounds/aww.mp3 new file mode 100644 index 0000000000..1a57bae92e Binary files /dev/null and b/Games/Taash Game/sounds/aww.mp3 differ diff --git a/Games/Taash Game/sounds/cash.mp3 b/Games/Taash Game/sounds/cash.mp3 new file mode 100644 index 0000000000..0aa9e10e6f Binary files /dev/null and b/Games/Taash Game/sounds/cash.mp3 differ diff --git a/Games/Taash Game/sounds/clap.mp3 b/Games/Taash Game/sounds/clap.mp3 new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/Games/Taash Game/sounds/clap.mp3 @@ -0,0 +1 @@ + diff --git a/Games/Taash Game/sounds/swish.m4a b/Games/Taash Game/sounds/swish.m4a new file mode 100644 index 0000000000..1e27ba6840 Binary files /dev/null and b/Games/Taash Game/sounds/swish.m4a differ diff --git a/Games/Taash Game/style.css b/Games/Taash Game/style.css new file mode 100644 index 0000000000..f0ce85e2cc --- /dev/null +++ b/Games/Taash Game/style.css @@ -0,0 +1,65 @@ +body { + background: url("https://images.pexels.com/photos/956999/milky-way-starry-sky-night-sky-star-956999.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"); + background-repeat: no-repeat; + background-size: cover; + + padding:10px; +} + + +.container { + margin: 0 auto; + text-align: center; + color: white; + width:75%; + +} + +.flex-blackjack-row-1, +.flex-blackjack-row-2, +.flex-blackjack-row-3 { + display: flex; + padding: 5px; + flex-wrap: wrap; + flex-direction: row; + justify-content: space-evenly; +} + +.flex-blackjack-row-2 div { + padding: 10px; + border: 1px solid black; + + flex: 1; + height: 350px; + text-align: center; +} + +.flex-blackjack-row-2 div img { + padding: 10px; +} + +table { + border: 3px solid black; + border-collapse: collapse; + padding:10px; + width:45%; + background-color: white; + text-align: center; +} +table td { + border: 2px solid black; +} + +.flex-blackjack-row-3 div { + padding: 5px; +} + +.flex-blackjack-row-3 button { + padding: 10 px; + margin-bottom: 10px; +} + +.flex-blackjack-row-2, .flex-blackjack-row-3{ + background-image: url(https://i.stack.imgur.com/q02th.jpg); + border: 3px solid black; +} diff --git a/README.md b/README.md index 105853b02f..a946f6e2d8 100644 --- a/README.md +++ b/README.md @@ -333,6 +333,7 @@ This repository also provides one such platforms where contributers come over an | [Brick Buster Game](https://github.com/kunjgit/GameZone/tree/main/Games/Brick Buster) | | [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy) |[Penguins Can't Fly](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Penguins_Can't_Fly)| +| [Taash_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Taash_Game)| @@ -397,4 +398,4 @@ Terms and conditions for use, reproduction and distribution are under the [Apach
-

Back to top

+

Back to top

\ No newline at end of file diff --git a/assets/images/Taash Game.png b/assets/images/Taash Game.png new file mode 100644 index 0000000000..4376fcc0c3 Binary files /dev/null and b/assets/images/Taash Game.png differ