Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Card, Deck and README.md with test files #11

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
da72fd6
Basics of card and deck class done. Test files working.
grissett83 Jan 21, 2015
59b8a0e
Fixed pep8 errors, added reshuffle and deal methods to the deck class…
grissett83 Jan 21, 2015
19a4bbc
Updated Player Class, added tests for Player. Added money attribute …
grissett83 Jan 22, 2015
0003d98
Forgot to add README.md to staging on previous commit.
grissett83 Jan 22, 2015
d9c7b28
Deleted /lib/blackjack/ files
grissett83 Jan 22, 2015
e088f8e
Updated some test files and added Hand class.
grissett83 Jan 22, 2015
5ccd1a5
Updated a few variable names in each file. Moved README to base dire…
grissett83 Jan 22, 2015
4c415c7
Added docstring to the beginning of hand.py
grissett83 Jan 22, 2015
3467a93
Finished basic layout for dealer using rule that dealer always stands…
grissett83 Jan 22, 2015
2f62722
Added Interface class with method to display the main menu and take u…
grissett83 Jan 22, 2015
0c20133
Added game options class. A container for keeping track of the games…
grissett83 Jan 22, 2015
b1a43ef
Updated the dealer to allow a hit on soft 17 rule to be used.
grissett83 Jan 22, 2015
cf8eb77
Added tests to the dealer test file to ensure hit on soft 17 was func…
grissett83 Jan 22, 2015
e9b0e6b
Updated the README.md file To Do lists to reflect completed aspects o…
grissett83 Jan 22, 2015
1df8bdd
Updated variable name in game_options, coded __init__ and create_hand…
grissett83 Jan 22, 2015
879b44f
Added methods and tests into game to check if a player wins, busts or…
grissett83 Jan 22, 2015
c7d06f5
Added tests and functionality for several of the game options.
grissett83 Jan 23, 2015
c752871
Added surrender and no surrender checks and tests.
grissett83 Jan 23, 2015
6cc5df8
Added no hit split aces functionality and tests
grissett83 Jan 23, 2015
7c05be2
Added no hit after double rules and tests.
grissett83 Jan 23, 2015
77d79fa
Added no hit split aces
grissett83 Jan 23, 2015
b99e4e9
Added split functionality and test
grissett83 Jan 23, 2015
c842d2b
Added double down functionality and test
grissett83 Jan 23, 2015
732dbe1
Added double down functionality and test
grissett83 Jan 23, 2015
a1c0cf9
Moved some functionality for player moves into player class from game…
grissett83 Jan 23, 2015
32f5eee
Added to options menu to the interface file, also added a method to m…
grissett83 Jan 24, 2015
a6cc8be
Added payout method and method to determine the player's available ac…
grissett83 Jan 24, 2015
91f9132
Updated several methods to work correctly with interface. Coded most…
grissett83 Jan 24, 2015
95b8d82
Fixed bug which crashed script if player bet more money than they had.
grissett83 Jan 24, 2015
00afbde
Fixed bug where player busting on last hand of split crashed game. F…
grissett83 Jan 24, 2015
8f05b25
Fixed bug where insurance failed to pay when dealer hit blackjack.
grissett83 Jan 24, 2015
2f4fa7c
Updated surrender to no longer require the dealer's upcard to be Ace.…
grissett83 Jan 24, 2015
f8e5889
Updated game test file to reflect argument changes to the surrender m…
grissett83 Jan 24, 2015
c44b49f
Fixed missing self reference in interface when checking for blackjack
grissett83 Jan 24, 2015
0712bab
Fixed bug where player would gain money if dealer hit blackjack
grissett83 Jan 24, 2015
45d55c7
Fixed bug where Aces weren't allowed to split when using the split by…
grissett83 Jan 24, 2015
1a37950
Added feature to disallow doubling more than one hand after split. A…
grissett83 Jan 24, 2015
8cda2ab
Updated the interface module - split the play_hand method into smalle…
grissett83 Jan 25, 2015
b8d1ba1
Fixed pep8 errors.
grissett83 Jan 25, 2015
6c71598
Added save feature.
grissett83 Jan 25, 2015
08a7378
Added some colors to the terminal display
grissett83 Jan 25, 2015
0da5903
Forgot to implement early surrender option into game. Done now.
grissett83 Jan 25, 2015
c151e46
Added requirements.txt
grissett83 Jan 26, 2015
13254bf
Fixed bug that caused insurance to end the hand without reporting res…
grissett83 Jan 26, 2015
f66604d
Restructured files to use __main__ from the root blackjack directory …
grissett83 Jan 26, 2015
3e5704f
Adding __main__ to git repository.
grissett83 Jan 26, 2015
398c340
Updated file structure once again to allow running python -m blackjac…
grissett83 Jan 26, 2015
618f98e
Updated a few things. Took out while True statements in places where…
grissett83 Jan 28, 2015
471a9cb
Added custom __len__ function to deck to make it easier to check card…
grissett83 Jan 28, 2015
61a7d55
Simplified user input section of play_game method in interface.
grissett83 Jan 28, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 149 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,150 @@
# Blackjack
Alan Grissett
[email protected]

* [Part 1](README_1.md)
* [Part 2](README_2.md)
The Iron Yard - Durham
Python Development - Cohort 3
[ Key:
+ - Implemented
* - Not Yet Implemented
? - Unsure if should be included in class
\ - Planned But Low Priority
]

Run Instructions: Run from the main blackjack directory using the command "python -m blackjack"

Blackjack Project

The goal of this project is to complete a fully functional console based
version of Blackjack. The game will allow the player to select options for
the rules used in the play of the game - including the number of decks used,
dealer hit/stand on soft 17, early/late surrender, hit/resplit aces,
insurance, double on 9/10/11 or 10/11 only and no double on split.

The game will be divided into classes for each component of the game.
The initial class plan is as follows and is subject to change:


+ <Card>: The Card class will contain the information about a single card in the
deck. Cards will have attributes for rank, suit and value. Numbered cards
are worth their face value, while Jacks, Queens and Kings are worth 10. Aces
are worth 1 or 11 depending on the player's current hand value. The Card
class will provide a method for updating the value of the ace if requested
to do so by the game.

The Card objects will be created and stored by the Deck class and will
subsequently be distributed to Hand objects assigned to the player and
dealer respectively.

To Do:
+ - Assign class attributes
+ - Add method to evaluate the value of Card
+ - Add Unicode representations of suits
+ - Add method for swapping value of Aces


+ <Deck>: The Deck class will be an object containing a collection of at least
one full deck of cards upon initialization. The Deck will construct a list
containing at least one of each card in a standard playing deck and then
use a random number generator to randomize the location of the cards within
the list. The Deck defaults to having a single set of 52 cards, but has an
optional argument to contain any number of decks (with a maximum of 8).
The Deck contains methods to reshuffle the deck and to remove cards from
the list and return their values to the requester.

To Do:
+ - Generate a list containing Card objects representing a full deck of cards
+ - Randomize card locations within the deck list
+ - Add optional class attribute to increase the number of decks of Card
objects created
+ - Add a method to remove a card from the card list and return the value
+ - Add a method to reshuffle the deck of cards


+/ <Player>: The player class object will contain the amount of money the
player has remaining to wager and a list of hands (multiple hands on split)
controlled by the player.

To Do:
+ - Add class attributes
+ - Add methods to increment or decrement remaining money
+ - Add name attribute
+ - Add method to save player state so the game can be resumed with current
money amount maintained


* <Dealer>: The Dealer class will contain a single Hand object corresponding
to the cards it is dealt. It will also contain a rule set for deciding
whether to hit or stand for it's given hand value.

To Do:
+ - Add class attribute
+ - Add basic decision rules
+ - Add optional rules based on user selected options


+ <Hand>: The Hand class will contain a list of cards currently associated
with a Player or Dealer. It will have a method for determining and returning
the current value of itself and a method to receive new cards from the deck
and add them to the class's Card list.

To Do:
+ - Add class attribute and initialization
+ - Add method to evaluate value of cards
+ - Add method to request change in the value of an ace if present in the hand
+ - Add method to receive Card objects and add them to the Hand's Card list


* <GameOptions>: The GameOptions class will store all of the user selected
rules for gameplay. Attributes will include an integer value between 1 and
8 representing the number of decks to be used in the game, as well as a
series of Boolean values with default values that will activate or deactivate
certain rule variations.

To Do:
+ - Add basic list of class attributes, starting with number of decks
+ - Add in common rule variations. No hit on soft 17 and Late/Early surrender
+ - Add in advanced rule variations


+ <Game>: The Game class will be the backbone of the game. It will store
the wager amount made by the player, created and distribute Hand objects to
the Player and Dealer and will control game flow based on hand
values held by the player and dealer. It will have methods to calculate
payouts based off of results of the game. Payouts will be 2:1 for a standard
win and 3:2 on blackjack. The Game class will pass the payout information
for use by the Player class to update the Player's money total. ?May create
the Dealer object and retrieve the ruleset from GameOptions.?

To Do:
+ - Add list of Game attributes
+ - Add method to distribute Hands to Player and Dealer
+ - Add method to check the status of the game by resolving Hand values
+ - Add method to distribute payouts to the player
+ - Add method for determining available actions for the player
+ - Add method to retrieve the ruleset from GameOptions and create the
Dealer based on currently selected rules. (Maybe in Blackjack class?)


+ <Main>: The Run class will be the driver script for the game.
It will control all of the program flow and interact with the Game and
Interface Classes to start new hands, request menu displays, request output
to the console from the Interface Class. This file will contain the
main method for the game, and will be the script executed to start the
game.

To Do:
+ - Add main method to initialize the game and start program flow


+ <Interface>: The Interface class will contain all of the ASCII text that
will be used for in-game card representations, menus and methods for
receiving input from the user.

To Do:
+ - Design main menu
+ - Design options menu
+ - Add method for updating options based on user input from options menu
+ - Add method for displaying current hands for the dealer and player to
the console
+ - Add method to display win/lose text after each hand
+ - Add control game flow to the interface
76 changes: 0 additions & 76 deletions README_1.md

This file was deleted.

77 changes: 0 additions & 77 deletions README_2.md

This file was deleted.

Empty file added blackjack/__init__.py
Empty file.
35 changes: 35 additions & 0 deletions blackjack/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from blackjack.game import Game
from blackjack.game_options import GameOptions
from blackjack.interface import Interface


class Main:

def main(self):
"""This is the launching method for the game. It displays the main menu,
receives menu selection and launches the options menu and the game when
prompted."""
interface = Interface()
options = GameOptions()

while True:
selection = 0
selection = interface.main_menu()
if selection == "1":
name = interface.get_name()
game = Game(options, name)
interface.play_game(game)
elif selection == "2":
game = Game(options, "None")
game = interface.load_game_menu(game)
if game:
interface.play_game(game)
elif selection == "3":
options = interface.options_menu(options)
elif selection == "4":
break


if __name__ == '__main__':

Main().main()
Loading