DEV Community

no momo
no momo

Posted on

Why a multiplayer party game doesn’t need a backend

I built SketchWordGen, a free Pictionary word generator. It has a word dealer, a countdown timer, a two-team scoreboard, and a custom-deck sharing feature. It has no database.

That's not laziness. When I broke down the "multiplayer" requirement, I found the amount of state that actually needs cross-device sync was zero.

The state boundary

The way you play Pictionary is: one person holds the phone, looks at the word, draws, then hands the phone to the other team. The device itself moves between people. Who already drew, how many seconds are left, Team A vs Team B — all of that lives inside one device, one tab, one game. Nothing extends beyond that boundary. So I didn't build a backend.

Dealing without repeats

Dealing without repeats is a Set plus a remaining array:

const used = new Set();
const remaining = [...allWords];

function deal() {
  if (remaining.length === 0) reshuffle();
  const i = Math.floor(Math.random() * remaining.length);
  const [word] = remaining.splice(i, 1);
  used.add(word);
  return word;
}

function reshuffle() {
  used.clear();
  remaining.push(...allWords);
}
Enter fullscreen mode Exit fullscreen mode

reshuffle just empties used and refills remaining. There's no "current round" concept because users don't need one — they know how many rounds they've played.

The one real bug: my first implementation used array.sort(() => Math.random() - 0.5). It's biased on some browsers — words near the front of the array got drawn noticeably more often. Switching to Fisher–Yates fixed it. That's the only detail in "random word dealing" worth a code comment.

The scoreboard

Pure in-memory state. I did not implement "Team B can't act while Team A is scoring," because physically the device is in Team A's hand — Team B can't click simultaneously. A surprising number of "concurrency problems" don't exist in single-device scenarios. That was the biggest correction to my mental model while building this.

When this architecture breaks

If I ever build "every player opens the page, remote play," localStorage won't cut it — I'd need WebSockets or at minimum a room service. Before that, I'd ask: can I degrade remote into "single device + video call"? If not, then I add a backend. This site doesn't have that need, so I haven't.

How to verify: open devtools → Network, play three rounds, watch for any requests from dealing, timing, or scoring. There aren't any.

The dealer itself is at sketchwordgen.com if you want to poke at the Network panel yourself.

Top comments (0)