Cuff the Bluff - Multiplayer Dice Bluffing Game
๐ Overview
Cuff the Bluff is a real-time multiplayer dice bluffing game based on the classic Liarโs Dice concept. Up to 15 players compete in a single room โ no account, no install, works on any modern browser. The last player standing with dice wins.
The entire stack runs on Cloudflare Workers + Durable Objects, giving each game room its own stateful WebSocket server at the edge with zero cold starts.
๐ Play the live game here: cuffthebluff.endra.in
๐ฒ How to Play
Each player starts with 5 dice (configurable 1โ10), rolled secretly. 1s are always wild and count toward any face bid.
On your turn, pick one action:
- Place a Bid โ claim there are at least N dice showing face F across all playersโ hidden dice (wilds included)
- Call Wilds โ switch to bidding on wilds only (quantity = โlastBid / 2โ)
- Raise Wilds โ increase the wild count by 1
- CUFF! โ challenge the current bid
Resolution: All dice are revealed. If actual count โฅ bid, the bid stood โ challenger loses 1 die. If actual count < bid, bluff was caught โ bidder loses 1 die. Lose all dice and youโre eliminated. Last player standing wins.
๐ Features
Core Gameplay
- Real-time multiplayer for up to 15 players per room
- Full bid validation: NormalโWild transitions, quantity escalation rules, wild scaling
- Round resolution with full dice reveal
- Bot AI opponents โ play vs 3 bots instantly without waiting for a lobby
Bot AI
- Probability-based strategy: estimates expected die counts from own dice + statistical averages
- Adaptive bluffing: 65% challenge rate on high bids, 8% on marginal ones
- Face selection based on highest count in botโs hand
- Human-like pacing: 900โ1200ms delay per decision
Lobby & Room Management
- 6-character room codes for instant sharing
- Configurable dice count per player (1โ10) and turn time limit (10โ120s)
- Host-only controls: start game, kick players, configure settings
- Automatic host transfer on disconnect
Reconnection & Session Handling
- Reconnect tokens stored in localStorage โ refresh the page to rejoin automatically
- 15-second grace period before turn auto-advances on disconnect
- Room auto-cleanup after 1 hour via Durable Object alarm
UI/UX
- CSS dice dot-pattern rendering with hover animations
- Turn countdown timer with visual alerts
- Round-end overlay with full bid resolution and dice reveal
- Player badges: HOST, YOU, BOT, AWAY with dice count and elimination status
- Dark theme with gradient UI, mobile-responsive
- โHow to Playโ help overlay and share room code button
๐ ๏ธ Tech Stack
Frontend
- Vanilla JavaScript + HTML + CSS (single self-contained HTML file, no framework)
- Web Audio API for sound effects (no external audio files)
Backend
- TypeScript
- Cloudflare Workers (stateless HTTP/WebSocket gateway)
- Cloudflare Durable Objects (one per room โ stateful, in-memory game state + WebSocket hub)
Infrastructure
- Wrangler CLI for build and deployment
- No external database โ all game state held in-memory per Durable Object instance
๐๏ธ Architecture
Stateless Worker + Stateful Durable Object Pattern
- Worker (
index.ts) โ routes WebSocket upgrade requests and serves the HTML frontend - Room Durable Object (
room.ts) โ one instance per room code; holds all game state, handles all WebSocket connections, enforces game rules, runs bot AI
This means each room is fully isolated, scales horizontally, and requires no database.
WebSocket Message Protocol
- Client โ Server: join, reconnect, placeBid, cuff, setDiceCount, setTimeLimit, kick, leave
- Server โ Client: joined (with reconnect token), roomState (full broadcast), yourDice (secret), error, kicked, roomNotFound
Reconnection Token System
- UUID tokens stored in Durable Object storage + client localStorage
- 1-hour expiry window prevents unauthorised rejoin after elimination
๐ Key Features in Action
๐ฒ Bluff or CUFF
Every bid is a gamble โ the tension builds as quantities escalate and players weigh the odds of calling CUFF at the right moment.
๐ค Play vs Bots Instantly
Jump into a 1v3 bot game in seconds. Bots use probability models to challenge and bid realistically.
โก Edge-Native Real Time
Cloudflare Durable Objects keep each roomโs state at the edge โ WebSocket latency is minimal regardless of where players are.
๐ Reconnect Without Losing Your Seat
Refreshing the page automatically rejoins your active game using the stored reconnection token.
๐ Deployment
- Hosting: Cloudflare Workers + Durable Objects (globally distributed edge)
- GitHub: github.com/vijevira/cuff-the-bluff
- Live at: https://cuffthebluff.endra.in