Skip to content
/ DeckPy Public

A collection of classic card games built with Python, emphasizing clean architecture and modular design.

License

Notifications You must be signed in to change notification settings

kay-rey/DeckPy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

50 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

DeckPy ๐Ÿƒ

A polished Python implementation of classic card games featuring clean architecture, comprehensive testing, and maintainable code quality.

๐ŸŽฏ Project Overview

This repository demonstrates solid Python development practices through the implementation of multiple card games. Built with modular architecture principles, DeckPy showcases object-oriented design, error handling, and maintainable code structure.

โœจ Key Features

๐Ÿ—๏ธ Architecture & Design

  • Modular Design: Clean separation of concerns between core components and game logic
  • Object-Oriented: Well-structured classes with clear responsibilities
  • Type Hints: Python type annotation support for better code quality
  • Dataclasses: Modern Python features for clean, maintainable code

๐ŸŽฎ Game Implementations

  • Blackjack: Casino-style implementation with core features
    • Split hands, double down
    • Multi-deck support with automatic reshuffling
    • Standard dealer rules
  • War: Classic two-player card game with complete rule implementation
    • Handles "War" scenarios with tied cards
    • Automatic hand replenishment from winnings pile
    • Edge case handling for insufficient cards

๐Ÿงช Quality Assurance

  • Testing Framework: pytest-based test suite for core components
  • Test Coverage: Tests for card logic, deck operations, and player actions
  • Input Validation: User input handling and error checking
  • Code Structure: Consistent formatting and organization

๐Ÿš€ Technical Features

  • Standard Library Only: Pure Python implementation using built-in modules
  • Efficient Design: Clean algorithms and data structures
  • Memory Management: Proper cleanup and resource handling
  • Cross-Platform: Works on Python 3.13+ environments

๐Ÿ—๏ธ System Architecture

src/
โ”œโ”€โ”€ core/           # Core game components
โ”‚   โ”œโ”€โ”€ card.py     # Card classes with game-specific value logic
โ”‚   โ”œโ”€โ”€ deck.py     # Deck management with multi-deck support
โ”‚   โ””โ”€โ”€ player.py   # Player state and game actions
โ”œโ”€โ”€ games/          # Game implementations
โ”‚   โ”œโ”€โ”€ blackjack.py # Blackjack game engine
โ”‚   โ””โ”€โ”€ war.py      # War game implementation
โ””โ”€โ”€ __init__.py     # Package initialization

tests/              # Test suite
โ”œโ”€โ”€ core/           # Core component tests
โ””โ”€โ”€ games/          # Game logic tests

๐Ÿ› ๏ธ Technical Requirements

  • Python: 3.13 or higher
  • Testing: pytest framework (optional)
  • Dependencies: None (pure Python standard library)

๐Ÿ“ฆ Installation & Setup

Prerequisites

# Ensure Python 3.13+ is installed
python --version

Clone & Install

# Clone the repository
git clone https://github.com/kay-rey/DeckPy.git
cd DeckPy

# Install testing dependencies (optional)
pip install -r requirements-test.txt

๐ŸŽฎ Usage

Quick Start

# Run the main game interface
python main.py

Game Selection

The application provides a command-line interface:

  1. Blackjack: Casino-style card game with betting
  2. War: Classic two-player card game
  3. Exit: Program termination

Game Features

Blackjack

  • Betting System: Money management with win/loss tracking
  • Player Actions: Hit, Stand, Double Down, Split
  • Dealer Logic: Standard casino dealer behavior
  • Multi-Hand Support: Handle split hands independently
  • Deck Management: Automatic reshuffling

War

  • Complete Rules: Full implementation including "War" scenarios
  • State Management: Hand depletion and replenishment handling
  • Betting Integration: Integrated with the betting system

๐Ÿงช Testing & Quality

Run Test Suite

# Run all tests
pytest

# Run specific test modules
pytest tests/core/test_card.py
pytest tests/games/test_blackjack.py

Test Coverage

  • Core Components: Tests for card, deck, and player logic
  • Game Logic: Testing of game rules and scenarios
  • Integration: Game flow testing

๐Ÿ”ง Development Practices

Code Quality Standards

  • Type Safety: Type annotation throughout codebase
  • Documentation: Docstrings and inline comments
  • Error Handling: Input validation and error checking
  • Structure: Clean, organized code layout

Design Patterns

  • Card Factory: Dynamic card creation based on game type
  • Strategy Pattern: Game-specific card value calculations
  • State Management: Game state handling and updates

๐Ÿ“Š Project Characteristics

  • Memory Efficient: Proper cleanup and resource management
  • Execution: Smooth gameplay with optimized logic
  • Extensible: Modular design allows adding new games
  • Maintainable: Clean code structure for easy updates

๐Ÿš€ Future Enhancements

Potential Features

  • Additional Games: Poker, Solitaire, Hearts
  • Network Play: Multiplayer capabilities
  • AI Opponents: Computer player improvements
  • Web Interface: Modern UI options
  • Statistics: Player tracking and leaderboards

Architecture Improvements

  • Plugin System: Dynamic game loading
  • Event System: Decoupled state management
  • Configuration: External game rule settings
  • Logging: Enhanced debugging capabilities

๐Ÿค Contributing

We welcome contributions that maintain the project's code quality and architectural standards.

Contribution Guidelines

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/Improvement)
  3. Implement with attention to code quality and testing
  4. Test thoroughly with the existing test suite
  5. Submit a pull request with detailed description

Development Standards

  • Test Coverage: Maintain existing test coverage
  • Code Style: Follow PEP 8 and project conventions
  • Documentation: Update docstrings and README as needed
  • Quality: Consider performance and maintainability

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘จโ€๐Ÿ’ป Author

kay-rey - Python Developer

  • GitHub: @kay-rey
  • Focus: Clean code, game development, Python architecture

๐ŸŒŸ Project Highlights

Technical Strengths

  • Clean Architecture: Well-structured, maintainable codebase
  • Modular Design: Easy to extend with new games and features
  • Quality Focus: Comprehensive testing and error handling
  • Performance: Efficient algorithms and data structures

Code Quality

  • Zero Dependencies: Pure Python standard library implementation
  • Type Safety: Full type annotation support
  • Documentation: Clear docstrings and code comments
  • Testing: Robust test suite for all components

โญ Star this repository if you appreciate clean, well-structured Python development with DeckPy!

Last updated: 2025-04-05 | Built with โค๏ธ and Python 3.13

About

A collection of classic card games built with Python, emphasizing clean architecture and modular design.

Topics

Resources

License

Stars

Watchers

Forks

Languages