GithubHelp home page GithubHelp logo

blackjack's Introduction

blackjack

CircleCI codecov

A ♠️ blackjack ♠️ game in the terminal

Installation

$ git clone https://github.com/pwildenhain/blackjack.git
$ cd blackjack
$ pipenv install

Play the game

$ python -m blackjack

blackjack's People

Contributors

jima80525 avatar pwildenhain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ajva2580

blackjack's Issues

Add Blackjack class

Attributes:

  • deck: Deck()
  • dealer: Dealer()
  • players: list of Player() instances

Methods:

  • Blackjack.play_game(): see rules below

    • This is what will be called in blackjack/__main__.py
    • Contains the main while loop to continue playing until done, asking players if they want to cash out, add more money, or continue
    • more to come...
  • Blackjack.take_bets(): Take bets from Blackjack.players. Store info about bets in respective Player() classes

  • Blackjack.deal(): Deal one card to each player.hand and then a facedown card to dealer.hand

  • Blackjack.play_round(): Play a single round of blackjack. Call the Blackjack.players.player.play() Blackjack.dealer.play() methods

Add Role class

Do this before implementing player and dealer classes
✔️ Make sure there are tests before proceeding

Add Dealer class

  • Dealer.play(deck: Deck) method
    • Unhide first card in Dealer.hand
    • Dealer.hit(card: Card) until Dealer.total >= 17

Add Player class

Attributes:

  • bank: The amount of 💰 player has left
  • bet: Amount player bet on a hand ♠️
  • moves : {0: "hit", 1: "stay"} for now, maybe add more later
    Methods:
  • self.choose_move(self):
    • Title-Case the moves for display
    • Return value from key-value
    • Isolating it like this makes testing easier
  • self.play(self, deck: Deck):
    1. keep_playing = self.choose_move() == "hit" and self.total < 21
    2. while keep_playing
      • self.hit(card=deck.pop())
      • if self.total >= 21: break
      • keep_playing = self.choose_move() == "hit"

Default Role.hand attribute to None

This way the Player() and Dealer() instances can be created before any cards are dealt. Needs to be the case if the players are going to make bets before getting dealt cards.

♻️ The Role.hand attribute needs to become a property with the @property.setter method that recalculates the Role.total each time a card is added.
♻️ Take the self.set_ace_value() out of Role.__init__()

Consider refactor of who wins round

A lot of logic in Blackjack.play_round() right now, especially with who wins the round -- consider moving this to a separate method Blackjack.determine_winner or something like that.

Add setup_game() utility function

Ask for inputs like

  • How many players
  • How much each player wants to play with

Returns

  • A Blackjack instance ready to have Blackjack.play_game() called

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.