Skip to content

Otheruser325/FivesDiceGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

FivesDiceGame

A simple yet popular dice game that can be played locally or online with friends!

๐ŸŽฎ Features

  • โœ… Local Multiplayer - Play with friends on the same device
  • โœ… Online Multiplayer - Play with friends online via Socket.io
  • โœ… Cross-Platform - Works on desktop browsers (mobile support coming)
  • โœ… Real-Time Gameplay - Instant updates across all players
  • โœ… Multiple Game Modes - Different configurations and difficulty levels

๐Ÿš€ Quick Start

Prerequisites

  • Node.js v18 or higher
  • npm or yarn

Local Development

# Clone the repository
git clone https://github.com/yourusername/FivesDiceGame.git
cd FivesDiceGame

# Run setup script (Windows)
setup.bat

# OR Run setup script (Mac/Linux)
bash setup.sh

# Start development server
npm run dev

# Open browser
http://localhost:8080

๐Ÿ“š Documentation

๐Ÿ—๏ธ Project Structure

FivesDiceGame/
โ”œโ”€โ”€ client/                 # Phaser game client
โ”‚   โ”œโ”€โ”€ scenes/            # Game scenes
โ”‚   โ”œโ”€โ”€ utils/             # Utilities (Socket.io, Audio, Animation)
โ”‚   โ”œโ”€โ”€ assets/            # Game assets
โ”‚   โ””โ”€โ”€ main.js            # Game entry point
โ”œโ”€โ”€ server/                # Node.js server
โ”‚   โ”œโ”€โ”€ index.js           # Express + Socket.io server
โ”‚   โ”œโ”€โ”€ lobbyManager.js    # Game lobby logic
โ”‚   โ”œโ”€โ”€ auth.js            # Authentication
โ”‚   โ””โ”€โ”€ utils/             # Server utilities
โ”œโ”€โ”€ web/                   # Marketing website
โ””โ”€โ”€ README.md              # This file

๐ŸŽฏ Domain Setup

To deploy with your domains (fivesdicegame.com):

  1. Server โ†’ api.fivesdicegame.com
  2. Game Client โ†’ play.fivesdicegame.com
  3. Website โ†’ fivesdicegame.com

See DEPLOYMENT.md for detailed instructions.

๐Ÿ”ง Server Technologies

  • Framework: Express.js
  • Real-Time: Socket.io v4.7+
  • Authentication: Passport.js (Discord, Google OAuth)
  • Session: Express-session with Redis support
  • Database: Local JSON (with Supabase migration option)

๐ŸŽฎ Game Technologies

  • Engine: Phaser 3
  • Language: JavaScript (ES6+)
  • Real-Time: Socket.io Client
  • Audio: Web Audio API

๐Ÿ“ก Online Multiplayer

The game uses Socket.io for real-time multiplayer:

  • โœ… Battle-tested and production-ready
  • โœ… Automatic fallback to polling if WebSocket unavailable
  • โœ… Excellent for turn-based games
  • โœ… Handles 5000+ concurrent connections

Why not Colyseus? Socket.io is simpler and more than sufficient for this turn-based dice game. Colyseus adds complexity without benefits for our use case.

๐Ÿงช Testing

Local Multiplayer Testing

  1. Open http://localhost:8080 in two browser windows
  2. Create lobby in window 1
  3. Join lobby in window 2
  4. Start game and play!

Network Testing

Connect from different devices on same network:

# Find your machine's IP
ipconfig  # Windows
ifconfig  # Mac/Linux

# Connect from remote device
http://<your-ip>:8080

๐Ÿ“Š Health Check

Monitor server status:

curl http://localhost:8080/health

Expected response:

{
  "status": "healthy",
  "timestamp": "2026-01-16T...",
  "redis": "not connected",
  "uptime": 12345
}

๐Ÿ” Environment Variables

Create server/.env file:

NODE_ENV=production
PORT=8080
CLIENT_ORIGINS=https://play.fivesdicegame.com
SESSION_SECRET=your-secret-key
DISCORD_CLIENT_ID=your-id
DISCORD_CLIENT_SECRET=your-secret

See server/.env.example for all options.

๐ŸŒ Production Deployment

Option 1: Vercel (Recommended)

  1. Push to GitHub
  2. Import project to Vercel
  3. Set environment variables
  4. Configure custom domains
  5. Done! Auto-deploys on each push

Option 2: DigitalOcean App Platform

  1. Connect GitHub
  2. Create App
  3. Configure environment
  4. Assign custom domain

Option 3: Self-Hosted

  1. Deploy to VPS/Dedicated Server
  2. Use PM2 or systemd for process management
  3. Set up Nginx/Apache reverse proxy
  4. Configure SSL with Let's Encrypt

See DEPLOYMENT.md for detailed steps.

๐Ÿ› Troubleshooting

"Connection Refused"

  • Verify server is running
  • Check port 8080 is accessible
  • See DEVELOPMENT.md for debugging tips

"CORS Error"

  • Ensure CLIENT_ORIGINS includes your domain
  • Restart server after changing .env
  • See SOCKET_IO_GUIDE.md for more details

"Socket.io Connection Timeout"

  • Server may be down
  • Check browser console for errors
  • Verify firewall allows connections

For more help, see SOCKET_IO_GUIDE.md.

๐Ÿ“ˆ Performance

  • Server capacity: 5000+ concurrent players
  • Message latency: < 100ms typical
  • Network bandwidth: < 5KB/min per player
  • Current game load: ~1-2 messages/second per player

See SOCKET_IO_GUIDE.md for optimization details.

๐ŸŽ“ Learning Resources

๐Ÿ“ License

This project is open source. See LICENSE for details.

๐Ÿ‘ฅ Contributing

Contributions welcome! Please feel free to submit Pull Requests.

๐ŸŽฏ Roadmap

  • Mobile app version
  • Tournament system
  • Player profiles and statistics
  • Spectator mode
  • Voice chat integration
  • Custom skins/themes

๐Ÿ“ž Support


Made with โค๏ธ for dice game lovers everywhere!

Releases

No releases published

Packages

No packages published

Languages