Skip to content

kyan32/blackjack-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🃏 Blackjack CLI

A simple, modular command-line Blackjack game written in Python.

🎯 Features

  • Play classic Blackjack against the dealer
  • Modular design: Card, Deck, Hand, and Game components
  • Dynamic point calculation for A (1 or 11)
  • Highscore tracking with highscores.json
  • Input validation, bet handling, and chip management

📂 Project Structure

blackjack-cli/ ├── game.py # Main game loop and UI logic ├── card.py # Card class with suit/rank and display ├── deck.py # Deck class: shuffling and dealing ├── hand.py # Hand class: card management and score calc ├── utils.py # Utility functions (input, clear screen, etc.) ├── highscores.json # JSON file storing top scores ├── test_hand.py # Simple unit test for Hand class ├── .gitignore # Ignore pycache, venv, and temp files ├── README.md # This file 

✨ Gameplay Rules (Implemented)

  • Each player starts with 1000 chips
  • Bet before each round (min 1 chip)
  • Blackjack (A + 10) pays 1.5x the bet
  • Bust if hand value > 21
  • Aces count as 11 or 1 based on total value
  • Dealer draws until 17 or more
  • Push (tie) if player and dealer have same score

🚀 Getting Started

1. Clone the repository

git clone https://github.com/your-username/blackjack-cli.git cd blackjack-cli

2. Run the game

python game.py

3. Run the test

python test_hand.py

Make sure test_hand.py is in the same directory as the game files, or adjust the import paths accordingly.

Requires Python 3.7+

📄 License

MIT License. Feel free to fork and contribute!


Have fun beating the dealer!

About

A simple command-line Blackjack game written in Python for COMP9001 Final Project.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages