https://github.com/chrisrobison/bj
Safe, secure and fair crypto blackjack server and client
https://github.com/chrisrobison/bj
Last synced: 20 days ago
JSON representation
Safe, secure and fair crypto blackjack server and client
- Host: GitHub
- URL: https://github.com/chrisrobison/bj
- Owner: chrisrobison
- License: mit
- Created: 2025-01-29T07:47:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-15T15:31:09.000Z (over 1 year ago)
- Last Synced: 2025-02-15T16:28:27.041Z (over 1 year ago)
- Language: JavaScript
- Size: 3.84 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ฐ Real-Time Multiplayer Blackjack
A modern, secure, real-time multiplayer Blackjack game implementation using WebSocket technology and Node.js. This project features a responsive web interface, secure authentication, and real-time game state management.
## โจ Features
- ๐ฎ Real-time multiplayer gameplay using WebSocket
- ๐ Secure user authentication with JWT
- ๐ฑ Responsive web interface with modern design
- ๐ฒ Multiple table support with configurable rules
- ๐ฐ Transaction management system
- ๐ Continuous game state synchronization
- ๐ Automatic reconnection handling with exponential backoff
- ๐ SSL/TLS encryption for secure communication
## ๐ ๏ธ Technology Stack
- **Frontend**:
- ๐ HTML5, CSS3, and vanilla JavaScript
- ๐ก WebSocket for real-time communication
- ๐ท Web Workers for background processing
- ๐ฑ Responsive design for mobile compatibility
- **Backend**:
- โก Node.js
- ๐ Express.js for REST API
- ๐ก WebSocket (ws) for real-time communication
- ๐๏ธ MySQL database with connection pooling
- ๐ JWT for authentication
## ๐๏ธ Architecture
The application follows a client-server architecture with several key components:
- **Client-Side**:
- ๐จ Game UI (`game.html`)
- ๐ฎ Game Controller (`gameController.js`)
- ๐ WebSocket Worker (`gameWorker.js`)
- ๐ Authentication handling (`login.html`, `signup.html`)
- **Server-Side**:
- ๐ฅ๏ธ Main server (`app.js`)
- ๐ Authentication service (`auth.js`)
- ๐ฒ Game state management (`gameStateManager.js`)
- ๐ฏ Table management (`table.js`)
- ๐ณ Transaction handling (`transactions.js`)
## ๐ Setup
1. Clone the repository:
```bash
git clone https://github.com/yourusername/blackjack-multiplayer.git
cd blackjack-multiplayer
```
2. Install dependencies:
```bash
npm install
```
3. Set up environment variables:
```bash
cp .env.example .env
```
Edit `.env` with your configuration:
```
PORT=4444
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=blackjack
JWT_SECRET=your_jwt_secret
```
4. Set up SSL certificates (required for secure WebSocket):
- Place your SSL certificates in the appropriate directory
- Update the paths in `app.js`
5. Start the server:
```bash
npm start
```
## ๐ Game Rules
- โ ๏ธ Standard Blackjack rules apply
- ๐ด Configurable number of decks (default: 6)
- ๐ฅ Dealer must hit on soft 17
- ๐ซ Double down allowed on any two cards
- โ๏ธ Split allowed (including split aces)
- ๐ฐ Minimum bet: $1, Maximum bet: $500
- ๐ฅ Maximum 5 players per table
## ๐ Security Features
- ๐ SSL/TLS encryption for all communications
- ๐ซ JWT-based authentication
- ๐ Password hashing using SHA-256
- ๐ Database connection pooling
- โ
Input validation and sanitization
- ๐ Secure session management
## ๐ป Development
To run the project in development mode:
```bash
npm run dev
```
This will start the server with nodemon for automatic reloading during development.
## ๐งช Testing
A test client is included (`test.html`) for debugging and testing the WebSocket functionality. To use it:
1. Start the server
2. Open `test.html` in your browser
3. Use the provided interface to test different game actions
## ๐ค Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## ๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
## ๐ Acknowledgments
- ๐ฐ Inspired by classic casino Blackjack games
- ๐ Built with modern web technologies
- ๐ Designed for scalability and performance