π Basic Blackjack
A simple blackjack app written in (mostly) native JavaScript. Uses some jQuery for cleaner syntax. No additional libraries or anything fancy
- Play blackjack against a computer-controlled dealer
- Dealer stands on all 17's
- Blackjack pays 3:2 odds (150%)
- Place bets: $25, $50, $100, $200
- Double down if you're feeling lucky
- Uses six 52-card decks
- All dealt cards are tracked to prevent duplicates
- Deck is shuffled before all 312 cards have been used
- True count is displayed on the bottom for card counting
- Running count is displayed when you hover over the true count
- Click the true count if you'd like to hide it
Β | Description | Β | Bet Amount |
---|---|---|---|
S |
Stand: stop drawing cards and let the dealer play | 1 |
$25 |
H |
Hit: draw 1 more card | 2 |
$50 |
D |
Double down: double bet, draw 1 card, and stand | 3 |
$100 |
N |
New hand: deal a new hand | 4 |
$200 |
π» Desktop
π± Mobile
- [TEST] = Added, needs more testing
- [WIP] = Work in progress
Strikethrough= Fixed or Cancelled
-
Occasionally freezes when shuffling deck -
Tie at 21 doesn't evaluate until you stand -
Some sounds are muted in specific browsers
Each browser handles JavaScript sound differently. Some are stricter than others or only play sounds tied to user input
-
Firefox on Windows plays all SFX (with audio site permission)
-
Chromium-based browsers play all SFX except "card_shuffle.mp3" on page load
-
Firefox on Android plays all SFX except "card_flip.mp3" on
hit()
-
Mobile rendering is inconsistent (but playable)
- Occasionally froze when looking for a new card
- Cause: crashed on
shuffleDeck()
ifnTotalCards > 311
- Fix: created offset to limit range of the check
- Cause: crashed on
// nTotalCards: total cards used by both players (per deck)
// nCardsInPlay: number of cards on the table (per hand)
// deckSize: size of all decks combined (312)
// decksLeft: number of remaining decks (1:6)
// fullDeck: array containing all six decks (0:311)
nCardOffset = (deckSize - nCardsInPlay) - 4;
if(nTotalCards > nCardOffset) {
nTotalCards = 0;
decksLeft = 6;
shuffleDeck(fullDeck);
}
- [TEST] Ties did not evaluate until
stand()
was called - Cause: condition was set before
checkFinalScore()
was called - Workaround: added tie check on
checkForWinners()
This is a lazy workaround until I completely remake the winner checks and merge checkFinalScore()
with checkForWinners()
- [WIP] Get rid of extraneous code and optimize
- Player strings and text:
number()
,toLocale()
,slice()
- Repeated strings/operations
- Hideous if/else blocks
- Player strings and text:
- [WIP] Clean up code with jQuery
- [TEST] Make mobile version
- Add a split feature
- This will require a 2nd game board for each player
- Make the cards smaller, change scaling, or re-orient the game board
- This will require a 2nd game board for each player
- Generate 2 to 6 decks
- Combine decks into a single pool of 312
- Track number of aces to subtract 10 if over 21
- Combine and clean up checks
checkForWins()
checkFinalScore()
- Use priority order to optimize checks
- [WIP] Optimize
getCardValue()
- Calcuate ace values with a single function
- [TEST] Check win condition for rare double bust
- [TEST] Properly handle rare double blackjack
- [WIP] Handle ties better
- Handle Blackjack vs regular 21 (Blackjack wins over 21)
- Change dealer strategy
- Draw to 16
- Stand on 17
- Basic strategy: when does a dealer hit on 16?
This doesn't seem significantly different than simply drawing to 17
- Expand the settings menu (similar to help popup)
- Save settings: sound, true count visibility, bet amount (use local storage)
- Save game progress: cards, scores, money, true count, running count, flags
- Update UI to properly render on a wider variety of devices
- Refresh my knowledge of CSS: viewport, vh, absolute/relative, etc.
- This could make the mobile port redundant if done properly
- [TEST] Display true count (card counting)
True count = (running count / decks remaining)
- [WIP] Use images for all buttons
- Add sound effects
- Add button to disable sound effects
- Add help menu with instructions and rules
- Make bet buttons look like casino chips
- Lower image sizes to improve loading time
- Add bet amount buttons
- Add buttons to increase/decrease bet by X dollars
- Add double down button
- Disable button with > 2 cards (standard casino rule)
- Add a help menu (simple popup with hide/close buttons)
NOTE: Blackjack typically used 2 to 8 decks shuffled together
- (Rare) Duplicate cards are dealt when deck is shuffled (duplicates don't carry over)
- Possible fix: force a shuffle after current hand if < X cards remain
- Decrease
nCardOffset
by more than4
The oldest working copy of this app: π» Desktop
Version | Date |
---|---|
Legacy | 5-15-23 |
Current | 11-8-23 |