DEV Community

UglyClancy
UglyClancy

Posted on

Terminal BlackJack!

For the final project on Codecademy's CS 101 I had to create a game that ran on terminal. I ended up choosing blackjack because I felt I could easily envision the code I'd have to build.

The game runs just like a casino game would minus the betting. It starts off by printing welcome messages and then using an input to get your name. After that it randomizes card selections and places them into variables that act as yours and the dealer's hands. Once the hands are created they are printed. Two cards show for you and one for the dealer. After that a series of if statements are used long with inputs to simulate hitting and staying. If you choose to hit, there will be another randomized card pulled from the dealing deck. You'll be asked to hit or stay again immediately after seeing your full hand. If you choose to stay the if statement breaks and your points will be added up and compared with the dealer's. Another series of if statements will be ran to print out the results (if you win, lose, tie, etc.).

Some special situations that are also ran include: a five card charlie that's inputted as an if check at the end of the hit or stay, going over 21 automatically ends the hit or stay section and tells you you lost, and finally there is an input for an ace choice so you can pick if you want to use it as a 1 or 11 value.

https://github.com/UglyClancy/Codecademy-101-Final

Top comments (0)