Cuff the Bluff - Multiplayer Dice Bluffing Game

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


๐Ÿ“Ž References