My first CLI game: Blackjack!

This is my first attempt at creating the classic casino game, Blackjack, on a text based interface, in Python.
It doesn’t use any libraries, it’s verbose and clunky but it does the trick.
Still have some debugging to do and some more features to add, but it’s my first game, and gosh I’m proud of it :smiley:
If anybody feels like having a look at it, here’s the github repo:
My Github
Any feedback or ideas are very welcome!

I really like how polished this looks, mine doesn’t look as polished and is too crowded. The spinner and the wait times make this really easy to follow, I’m going to play with that on mine when I have a chance.

I have two ideas that might help you expand on the game and explore some areas of coding:

First I’d try making a deck and then pulling cards out of the deck, I think your code would actually be more concise with this method.

number = [2, 3, 4, 5, 6, 7, 8, 9, 10, "A", "J", "Q", "K"]
suites = ["Clubs", "Spades", "Diamonds", "Hearts"]
deck = [[x, y] for x in number for y in suites]

Then using random.shuffle and .pop() to grab from the deck of 52 cards and use int(deck[0]) to calculate the score (with some if statements for the A-K)

Second (after you’ve done the above): Instead of a Blackjack class, try making a Player class. Then instantiate both a player and a dealer from the one class and create the game from there. You could also make a Deck class, which is completely unnecessary, but it will help get a grasp on using classes. So the Player Class (whether player or dealer) “hits” and the Deck class pulls out a “card” and puts it into the Players “hand”.

Great job!

Here is mine: https://github.com/stewiegreen/Blackjack/blob/master/Blackjack.py

My next goals are getting the cards to show up a “Ace or Spades” rather than [“Ace”, “Spades”] (the code is there, but I haven’t worked it in), betting, and multiplayer (which is good reason to make Player a class).

It was great to see another perspective to the game!
If we were to mix our projects it’ll be a badass blackjack sim.
I actually thought that your version was cleaner, but you went a bit overboard with the classes. There’s too many of them and it took me quite a while to understand what each were for.
Another issue was that the game mechanics were on an infinite loop, but the fix was easy:

# for an input statement first print the message to the user:
print("Enter your name below: "
player_name = input()
print(f"Hello {player_name}!")

Hope you don’t mind that I made a pull request on git, since I was looking at the code I went ahead and gave it my 2 cents :upside_down_face:

For my game, you’re right, I need to set up a deck with a finite number of cards. Also, I now realize that the face cards are worth 10 points, not 12 13 14 as in my game.
It wouldn’t hurt a class or 2 more, for some better organisation.
Let me know if you work on the new functionality – multiplayer – and update the files on github :slight_smile:

1 Like

Not at all! This is the exact reason I shared my project!

I simplified the game logic a lot. It’s a lot cleaner.