Blackjack, also known as twenty-one, is a comparing card game between usually several players and a dealer, where each player in turn competes against the dealer, but players do not play against each other. It is played with one or more decks of 52 cards, and is the most widely played casino banking game in the world.
- Clone the repo
- npm install
- npm test
const blackjack = require('./dist/bundle')
const { Player, Game } = blackjack
const players = {
player: new Player({name: 'Sam'}),
dealer: new Player({name: 'Dealer'})
}
const game = new Game(players)
const winner = game.start().play()
Here are the rules
- create a single deck of playing cards
- two players (called Sam and the Dealer) who will play against each other
- each player is given two cards from the top of a shuffled deck of cards
- determine score of a hand[1]
- check if either player has blackjack (21) with their initial hand and wins the game
- if neither player has blackjack then Sam can start drawing cards from the top of the deck
- Sam should stop drawing cards from the deck if their total reaches 17 or higher
- Sam has lost the game if their total is higher than 21
- when Sam has stopped drawing cards the Dealer can start drawing cards from the top of the deck
- the Dealer should stop drawing cards when their total is higher than Sam.
- the Dealer has lost the game if their total is higher than 21
- determine which player wins the game