Skip to content

Blackjack game using Vanilla Javascript - Functional programming principles

Notifications You must be signed in to change notification settings

K2adir/BlackJack-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blackjack Game

This is a simple Blackjack game built using HTML, CSS, and JavaScript. It follows the basic rules of Blackjack, where the player and dealer are dealt two cards each and the goal is to get as close to 21 points as possible without going over. The player can choose to "hit" and receive another card, or "stand" and keep their current hand. The dealer must continue to hit until their hand reaches 17 points or higher.

Getting Started

To play the game, simply open the index.html file in a web browser. The game will be displayed in the browser window and can be played using the mouse.

Gameplay

  1. Click on the banner when the game launches.
  2. Set the bet amount. You can bet 0.
  3. Deal two cards to both the player and the dealer.
  4. The player can choose to hit or stand by clicking the corresponding button.
  5. If the player chooses to hit, they will receive another card.
  6. If the player chooses to stand, the dealer will start hitting until their hand reaches 17 points or higher.
  7. If the dealer's hand exceeds 21 points, the player wins the game.
  8. If the dealer's hand is higher than the player's hand without exceeding 21 points, the player loses the game.
  9. If the player and dealer have the same score, the game is a "push" and the player's bet is returned.

Features

  • Uses 100% Vanilla JavaScript, without any libraries.
  • Follows functional programming principles.
  • Generates game cards with a JavaScript Class and CSS.
  • Displays the current card values of the player and the dealer.
  • After each round, the UI displays the outcome.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

This project incorporates code snippets and logic from various sources. All of the logic has been rewritten or converted from other languages/frameworks to vanilla JavaScript. Some functions have been rewritten by combining logic from multiple sources, while others have been taken from the source and improved for consistency and readability.

  1. https://scrimba.com/playlist/p3py7U7
  2. https://github.com/jacquelynmarcella/blackjack
  3. https://wsvincent.com/javascript-object-oriented-deck-cards/
  4. https://www.youtube.com/watch?v=Bj6lC93JMi0
  5. https://www.youtube.com/watch?v=NxRwIZWjLtE
  6. https://www.youtube.com/watch?v=bMYCWccL-3U&t=1845s
  7. https://github.com/jarodburchill/blackjack-react-app
  8. https://github.com/chirag-23/Black-Jack-Game
  9. https://codepen.io/pmk/pen/GgrJRq (Poker chips)

and numerious Google searches and indie blogs.

Future improvments

  • Some functions will be combined to reduce number of functions
  • CSS Framework will be adopted for consistency and improved design
  • Mobile version will be made
  • High Score system will be implemented and perform local save
  • Difficulty settings
  • Import cards as Json
  • Re-write using TypeScript
  • Easter eggs

About

Blackjack game using Vanilla Javascript - Functional programming principles

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published