It's browser-based blackjack... With React, Jack.
To play, just click here!
- React.js
- TypeScript
- Vite (for build, rollup, and dev server)
Clone this Git repository, navigate to its root directory, and run:
npm install
npx vite
- Set aside all
Ace
cards; Do not count them:- The value of each Ace card will be calculated last because they have their own logical system that depends on the final total of
non-Ace
cards
- The value of each Ace card will be calculated last because they have their own logical system that depends on the final total of
- Add up the score of every card that is NOT an Ace card:
- Kings, Queens, and Jacks ALL have a value of
10
- ex: A hand that contains
[9, Q, 3]
will equal22
- Kings, Queens, and Jacks ALL have a value of
- Once you have determined the final sum of all non-Ace cards, iterate through each Ace card in the player's hand and use the following logic:
- Does adding
11
to the player's total make the player's scoregreater than 21
? If not, add11
to the total. If yes, add only1
to their total score
- Does adding
In src/util/gameMethods.ts
, you'll find two methods called evaluateCssClassFor___Card()
.
Every time a card is dealt to a player, we run this function for each card and apply the class to each card so that we can assign a specific CSS animation to it.