The Core Dilemma: Cryptographic Secrecy vs. Live Sync

In Sheriff of Nottingham, players place 1 to 5 goods into a sealed merchant bag, declare a single legal good to the player acting as Sheriff, and negotiate bribes to pass through the city gates uninspected.

In typical multiplayer games, the server broadcasts the global game state to all connected clients. But in a bluffing game, if the client receives the secret contents of another player's bag—even hidden behind CSS opacity—any player opening browser DevTools can inspect the network payload and instantly know if the merchant is lying. Zero-knowledge fairness requires that secret cards are physically isolated server-side until the Sheriff formally unsnaps the bag.

Server-Authoritative State with Colyseus 0.18

We chose Colyseus because of its strongly typed schema serialization and room-based WebSocket protocol. Instead of manually synchronizing individual events, Colyseus tracks schema state changes and transmits binary byte deltas to clients.

To protect hidden information, we decoupled the server-side authoritative state into public and private layers:

Decoupling private player data from public serialized schema state in Colyseus.typescript
import { Room, Client } from "colyseus";
import { GameState, MerchantBag, Card } from "./schema";

export class NottinghamRoom extends Room<GameState> {
  // Authoritative server-only tracking of hidden bag contents
  private secretBags = new Map<string, Card[]>();

  onDeclareBag(client: Client, declaredGood: string, declaredCount: number) {
    const player = this.state.players.get(client.sessionId);
    if (!player || this.state.currentPhase !== "PACK_BAG") return;

    // Public state: Everyone sees HOW MANY cards were packed and the verbal declaration
    player.bagCardCount = declaredCount;
    player.verbalDeclaration = declaredGood;

    // The actual card entities remain in this.secretBags and NEVER touch the state schema!
    this.broadcastPatch();
  }

  onInspectBag(sheriffClient: Client, targetSessionId: string) {
    // Only when inspection formally resolves are cards published to the public state
    const revealedCards = this.secretBags.get(targetSessionId) ?? [];
    this.state.revealedBag.assign({ cards: revealedCards });
  }
}

Zero Asset Downloads: Procedural Web Audio

To keep the game instant-loading without megabytes of MP3 assets, we implemented a procedural Web Audio synthesizer. Crackling tavern embers, wooden table thumps, sliding coins, and triumphant brass fanfares are synthesized directly in the user's browser using oscillators, white noise buffers, and biquad filter envelopes.

The result: the entire game bundle loads in under 350 KB while delivering a tactile medieval tabletop atmosphere.

Testing Rigor: 114 Tests with Vitest

Edge cases in social tabletop games are notoriously complex: What happens when a player disconnects during inspection? How are King and Queen tiebreaker bonuses split when two players tie on Cheese quantities? How does debt liquidation work if an innocent merchant is falsely inspected?

We wrote 114 automated tests using Vitest covering every edge case in official 2nd Edition rules. This guarantees that game sessions proceed without desyncs, illegal moves, or corrupted room state.