Dasio/deathroll

โ˜… 0Forks 0TypeScriptGitHub โ†—Compare

README

๐ŸŽฒ DeathRoll - Multiplayer Dice Game

Note: This project was fully vibe coded with Claude Code.

A real-time multiplayer dice game built with Next.js and WebRTC. Players take turns rolling dice with decreasing ranges until someone rolls a 1 and loses. Features team mode, statistics tracking, smart reconnection, and PWA support.

โœจ Features

  • ๐ŸŽฎ Real-time Multiplayer - Peer-to-peer gaming using WebRTC (no server needed!)
  • ๐Ÿ‘ฅ Flexible Team Mode - Any team combination (1v2v3, 2v2, 1v1v1, etc.)
  • ๐Ÿ“Š Statistics Dashboard - Track wins, losses, streaks, and achievements
  • ๐Ÿ”Œ Smart Reconnection - Auto-reconnect with network quality indicator
  • ๐Ÿ“ฑ PWA Support - Install on mobile/desktop, works offline
  • โšก Real-time Sync - State synchronization across all players
  • ๐ŸŽจ Custom Avatars - Emoji avatars and color themes for each player
  • โŒจ๏ธ Keyboard Shortcuts - Space/Enter to roll dice

๐Ÿš€ Quick Start

Development

# Install dependencies
npm install

# Run development server
npm run dev

# Open http://localhost:3000

Production Build

# Build static export
npm run build

# Output in ./out directory

๐ŸŽฎ How to Play

  1. Host a Game

    • Click "Host Game"
    • Share the room code with players
    • Configure teams (optional)
    • Start the game when everyone joins
  2. Join a Game

    • Click "Join Game"
    • Enter the room code
    • Choose your name and avatar
    • Wait for host to start
  3. Gameplay

    • First roll: 1-100
    • Each subsequent roll: 1-(previous result)
    • Roll a 1 โ†’ You lose!
    • Last player standing wins

๐Ÿ“ฆ Tech Stack

  • Framework: Next.js 16 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • WebRTC: PeerJS
  • PWA: Service Workers + Web App Manifest
  • State: React Hooks + Context

๐ŸŒ Deployment

Deploy to GitHub Pages, Vercel, Netlify, or Cloudflare Pages:

# GitHub Pages (automatic via Actions)
git push origin main

# Vercel
vercel --prod

# Netlify
netlify deploy --prod --dir=out

See DEPLOYMENT.md for detailed deployment instructions.

๐Ÿ“ฑ PWA Installation

After deployment:

  1. Visit your app URL in Chrome/Edge
  2. Look for "Install app" prompt
  3. Or: Menu โ†’ "Add to Home Screen"
  4. App works offline after first visit

๐Ÿ”ง Configuration

Optional: TURN Server

Improve connection reliability (85% โ†’ 99%) by configuring a TURN server:

# .env.local
NEXT_PUBLIC_TURN_URL=turn:your-server.com:3478
NEXT_PUBLIC_TURN_USERNAME=username
NEXT_PUBLIC_TURN_CREDENTIAL=password

Free TURN providers: Metered.ca, Twilio

Optional: Custom Base Path

For GitHub Pages at username.github.io/repo-name/:

NEXT_PUBLIC_BASE_PATH=/repo-name npm run build

๐Ÿ“Š Statistics

Track your performance at /stats:

  • Win/loss record and win rate
  • Current and longest streaks
  • Total rolls and average roll
  • Achievements (Fastest Win, Comeback, etc.)
  • Global leaderboard
  • Export/share stats

๐ŸŽฏ Game Modes

Free-for-All (Default)

  • 2-8 players
  • Last player standing wins

Team Mode

  • Create any team combination
  • 1v2v3, 2v2, 3v3, etc.
  • Teams share turns
  • Eliminate entire team when any member rolls 1

๐Ÿ”Œ Connection Features

  • Auto-reconnect on network drop
  • Network quality indicator (excellent/good/poor)
  • State persistence survives page refresh
  • Exponential backoff prevents spam
  • Manual retry after failed attempts

๐Ÿ“ Project Structure

deathroll/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app/              # Next.js app routes
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx      # Home page
โ”‚   โ”‚   โ”œโ”€โ”€ host/         # Host game page
โ”‚   โ”‚   โ”œโ”€โ”€ play/         # Join game page
โ”‚   โ”‚   โ””โ”€โ”€ stats/        # Statistics dashboard
โ”‚   โ”œโ”€โ”€ components/       # React components
โ”‚   โ”‚   โ”œโ”€โ”€ game/         # Game-specific UI
โ”‚   โ”‚   โ”œโ”€โ”€ ui/           # Reusable UI components
โ”‚   โ”‚   โ””โ”€โ”€ pwa/          # PWA components
โ”‚   โ”œโ”€โ”€ hooks/            # React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ useHostGame.ts
โ”‚   โ”‚   โ””โ”€โ”€ usePlayerGame.ts
โ”‚   โ”œโ”€โ”€ lib/              # Core logic
โ”‚   โ”‚   โ”œโ”€โ”€ game/         # Game rules & state
โ”‚   โ”‚   โ”œโ”€โ”€ peer/         # WebRTC peer management
โ”‚   โ”‚   โ”œโ”€โ”€ statistics.ts # Stats tracking
โ”‚   โ”‚   โ””โ”€โ”€ storage.ts    # LocalStorage helpers
โ”‚   โ””โ”€โ”€ types/            # TypeScript types
โ”œโ”€โ”€ public/               # Static assets
โ”‚   โ”œโ”€โ”€ manifest.json     # PWA manifest
โ”‚   โ”œโ”€โ”€ sw.js            # Service worker
โ”‚   โ””โ”€โ”€ icons/           # App icons
โ””โ”€โ”€ scripts/             # Build scripts

๐Ÿค Contributing

Contributions welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License

MIT License - feel free to use this project for anything!

๐ŸŽฎ Live Demo

Play now: https://Dasio.github.io/deathroll/


Built with โค๏ธ using Next.js, WebRTC, and good vibes

Contributors

Dasio

Issues