Giter Site home page Giter Site logo

bmordan / blackjack Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 36 KB

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.

JavaScript 100.00%

blackjack's Introduction

BlackJack

yep cards

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.

Install

  1. Clone the repo
  2. npm install
  3. npm test

Usage

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

Model the game

  • 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

Rules to implement

  • 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.