Git Product home page Git Product logo

blackjack-api's Introduction

Blackjack API

This project utilizes the Deck of Cards API to and the Chalice microframework play a game of blackjack.

Plans

  • Breakout routes into their own files
  • Refactor project to components
  • Improve code quality
  • Implement different rules for blackjack for winning conditions

Documentation

Usage

Starting Chalice

Local Server

Chalice run locally so that server access isn't required.

$ chalice local
Serving on localhost:8000

Status

To get the status of the API, use the /status route.

$ curl http://localhost:8000/status
{
  "status": "OK",
  "date": "2016-06-18 10:31:58.671028"
}

Status with Message

A callback message can be sent with the status URL.

$ curl http://localhost:8000/status?message=Hello
{
  "status": "OK",
  "date": "2016-06-18 10:32:49.529086",
  "message": "Hello"
}

Starting a New Game

To start a new game, use the /blackjack/new route. This will reset both the players' hand as well as reshuffle the deck. Each player gets a 2 cards to start off with. If either player gets 21 (Blackjack), the game ends immediately.

$ curl http://localhost:8000/blackjack/new
{
  "player": {"hand": ["9D""5H"], "value": 14},
  "dealer": {"hand": ["0C""8H"], "value": 18}, 
  "message""Deck is ready to be played. Please draw a card.",
  "status""success"
}

Draw a Card

If the player wishes to draw another card, use the /blackjack/draw route. If the player hand value is over 21 after drawing, the player gets busted and loses the game.

$ curl http://localhost:8000/blackjack/draw
{
  "player": {"hand": ["9D""5H""7S"], "value": 21},
  "message""You drew a 7 of SPADES. Draw or hold.",
  "status""success"
}

Hold Hand

If a player wants to hold current hand, use the /blackjack/hold. This will force the dealer to draw until they either beat the player or bust. If dealer is successful, they win.

$ curl http://localhost:8000/blackjack/hold
{
  "dealer": {"hand": ["0C""8H""KC"], "value": 28},
  "message""Dealer busted! You win!",
  "status""success"
}

blackjack-api's People

Contributors

stetsentech avatar

Watchers

James Cloos avatar  avatar

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.