
# ๐ด Midnight Luxury Poker
A sophisticated, real-time Texas Hold'em poker game built with Flask-SocketIO backend and modern frontend. Features AI opponents with multiple difficulty levels and a luxurious casino-themed interface.
## โจ Features
### ๐ฎ Gameplay
- **Real-time Texas Hold'em** with full poker rules
- **Multiplayer support** - Play with friends or AI opponents
- **Smart AI opponents** with three difficulty levels (Easy, Normal, Hard)
- **Complete hand evaluation** and pot management
- **Side pot handling** for all-in scenarios
- **Responsive design** that works on desktop and mobile
### ๐จ User Experience
- **Luxury casino theme** with midnight black and gold accents
- **Smooth animations** for card dealing, chip movements, and pot distribution
- **Intuitive betting interface** with slider and preset bet buttons
- **Real-time game state updates** with Socket.IO
- **Winner announcements** with hand information
### ๐ Technical
- **Modular architecture** with separated game logic and UI
- **Thread-safe game engine** with proper locking
- **Database integration** for player persistence
- **Comprehensive error handling** and logging
- **Easy deployment** with production-ready configuration
## ๐ Quick Start
### Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
- Modern web browser with JavaScript enabled
### Installation
1. **Clone or unpack the project**
```bash
# If using the unpacker
python unpacker.py poker_project.md
-
Run automatic setup
This will:
- Check your Python environment
- Install required dependencies
- Create configuration files
- start development server
-
Manual setup (optional)
# Install dependencies pip install -r requirements.txt # Start the server python run.py
-
access the game
Open your browser and navigate to:
- Enter your player name in the lobby
- Add AI opponents using the difficulty buttons
- Click “Start Game” to begin
- The game automatically handles dealing and betting rounds
- blind:The small and big blinds are automatically posted
- pre flop: Get your hole cards and start betting
- flop: Three community cards are revealed
- turn: Fourth community card revealed
- River:Final Community Card Revealed
- showdown: Remaining players show hands, best hand wins
- fold: Discard your hand and sit out of the current round
- check: Stay in the game without betting (call when there are no bets)
- call out: Match current bet amount
- Raise: Increase current bet (must meet minimum raise requirements)
- in all: Bet all your remaining chips
midnight-luxury-poker/
โโโ ๐ app/ # Backend application
โ โโโ __init__.py # Flask app factory
โ โโโ extensions.py # Database and SocketIO initialization
โ โโโ ๐ poker/ # Poker game logic
โ โโโ __init__.py # Blueprint registration
โ โโโ models.py # Database models (User)
โ โโโ game.py # Core game logic (Game, Player, Deck classes)
โ โโโ ai.py # AI strategies (Easy, Normal, Hard)
โ โโโ events.py # SocketIO event handlers
โ โโโ routes.py # HTTP API endpoints
โ โโโ exceptions.py # Custom game exceptions
โโโ ๐ frontend/ # Frontend assets
โ โโโ index.html # Main HTML file
โ โโโ style.css Luxury casino styling
โ โโโ script.js # Client-side game logic
โโโ ๐ run.py # Main server entry point
โโโ ๐ start_server.py # Automated setup script
โโโ ๐ config.py # Application configuration
โโโ ๐ requirements.txt # Python dependencies
โโโ ๐ .env.example # Environment variables template
create a .env from file .env.example,
# Application Security
SECRET_KEY=your-super-secret-key-here-change-in-production
# Debug & Development
FLASK_DEBUG=True
FLASK_RUN_HOST=127.0.0.1
FLASK_RUN_PORT=5000
# Database
DATABASE_URL=sqlite:///poker.db
# CORS Settings (production)
# CORS_ALLOWED_ORIGINS=http://localhost:3000,https://yourdomain.com
modified config.py To adjust:
DEFAULT_CHIPS: initial chip count (default: 10000)SMALL_BLIND,BIG_BLIND: blind quantitiesMAX_PLAYERS_PER_GAME:Maximum players per table
๐ฎAI difficulty level
- Makes random decisions with basic strategy
- Good for beginners learning the game
- sometimes acts suspicious
- Uses to evaluate hand strength
- Considers position and pot odds
- balanced aggression and caution
- Advanced hand reading and range analysis
- Position-Aware Betting Strategies
- Pot Odds and Implied Odds Calculation
- capable of bluffing and semi-cheating
join_game:Join the game roombet
start_game: start a new handplayer_action:Submit Player Action"action": "fold
game_state_update:real time game statusgame_over: Round ends with winnerserror: error notifications
POST /api/user: Create new userGET /api/user/: get user informationPOST /api/reset_user:reset user chipsGET /api/games: List active gamesGET /api/game/:Get specific game status
- set
FLASK_DEBUG=FalseIn.env - generate a strong
SECRET_KEY - Configure production database (PostgreSQL recommended)
- set proper CORS origin
- Use Gunicorn for production servers:
gunicorn -k eventlet -w 1 run:app
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "run.py"]
Server will not start:
- Check Python version (requires 3.8+)
- Verify that all dependencies are installed
- check port 5000 is available
Connection errors:
- Ensure that the server is running
- Check browser console for WebSocket errors
- Verify CORS settings if accessing from different domain
Game Logic Issues:
- Check server logs for error messages
- Verify Database File Permissions
- Reset game state if necessary
- Server Log:
poker_server.log - Real-Time Log: Browser Developer Console
- fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature, - Commit your changes (
git commit -m 'Add amazing feature', - push the branch (
git push origin feature/amazing-feature, - open a pull request
- Follow PEP 8 for Python code
- Use meaningful commit messages
- Add tests for new features
- Update the document accordingly
This project is licensed under the MIT License – see the license file for details.
- Poker hand evaluation logic inspired by open-source poker libraries
- UI design inspired by luxury casino aesthetics
- Socket.IO for real-time communication capabilities
- Flask community for excellent web framework documentation
Enjoy your game of Midnight Luxury Poker!
For questions or support, please see the Issues section or contribute to the documentation.
This README provides:
1. **Comprehensive overview** of the project and its features
2. **Easy setup instructions** using your automated scripts
3. **Detailed technical documentation** of the architecture
4. **Game rules and AI descriptions** for users
5. **API documentation** for developers
6. **Deployment guides** for production
7. **Troubleshooting section** for common issues
The structure follows best practices for open-source projects and should help both users and developers understand and work with your codebase effectively.