logo
By Lawrence

5 minutes

The Deck and the Deal Queue

The betting core runs as pure data: the stacks, the pot, and a pointer to whose turn it is. But there is nothing to bet on yet. The table needs a deck — and under that sits a harder question. Soon this becomes a four-seat game, and every player runs the same code on their own machine. So how do all four agree on the exact same shuffle? Get that wrong, and one player sees the ace of spades while another sees a seven.

The deck builds no meshes and draws nothing on screen. It makes card ids as strings and announces each one over the bus — and the way it shuffles is the key to the whole multiplayer story.

A dealer's hands sending a fanned stream of glossy playing cards arcing across an emerald-green felt table, several cards caught mid-flight toward seats around the rim, a freshly shuffled deck stacked at center, faint glowing numbered arrows tracing the round-robin deal order from seat to seat, warm overhead light, near-black surround.

Add the Dealer to the scene

Open src/scenes/poker.json and add one entity next to Felt:

src/scenes/poker.json
"Dealer": {
  "components": {
    "DeckDealer": {
      "playerCount": 4,
      "cardsPerPlayer": 2,
      "riverSize": 5,
      "localIndex": 0,
      "roomCode": "table-7",
      "handNumber": 0
    }
  }
}

The component source already lives at src/components/DeckDealer/. Lesson 1's bjs download scene PokerTableDirector --all pulled it in. These settings spell out Texas Hold'em. playerCount: 4 and cardsPerPlayer: 2 mean four seats with two hole cards each. riverSize: 5 is the community row. localIndex: 0 marks which seat is yours. And roomCode: "table-7" is the interesting one — it is half of a seed.

Continue reading

Unlock the Full Course

Every lesson, the runnable examples, and the finished build — yours to keep.

$9one-time

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search