Card games
Write cards as short codes and see hands dealt, named and scored.
What it shows
Write playing cards as short codes, and let the cards plugin deal, name and score them.
What you learn
One rule that hands a fenced block to a plugin, cards as a rank and a suit, a hold'em hand you step through, five-card hands named and ranked, blackjack totals.
Try this
- Change the river from
Khto2c, and at the river Cy's four sevens win instead.
Poker night
Six players, one table, and the hand everyone was still talking about on Saturday.
Press ▶ or the arrow keys to deal the flop, the turn and the river. Each hand says what it holds so far, and at the river the winner lights up.
Showdown practice
No board here: each player shows five cards, and the best hand is marked.
Blackjack, after midnight
The dealer's cards come first. An ace counts 11 or 1, whichever keeps a hand at 21 or under.
Chips at the end of the night
| Player | Bought in | Left with |
| Ana | 2,000 | 6,350 |
| Bo | 4,000 | 1,100 |
| Cy | 2,000 | 2,900 |
| Dee | 2,000 | 1,600 |
| Eli | 2,000 | 0 |
| Flo | 2,000 | 2,050 |
Next game: Friday 27 November, at Bo's. He wants a rematch.
How it's made
- A card is its rank and its suit:
Asis the ace of spades,10hthe ten of hearts,Kdand7cthe king of diamonds and the seven of clubs. - Inside a
cardsblock,hand Ana:gives a player their cards, and a|after them adds a note.board:lays the shared cards, with|between the flop, the turn and the river. game: pokerranks five-card hands, andgame: blackjackcounts totals. One rule in the rules block hands everycardsblock to the plugin.
Try it yourself
- Change the river from
Khto2c. At the river Cy's four sevens win the hand of the night. - In the showdown, change Eli's cards to
Ah Kh Qh Jh 10h. A royal flush beats Dee's full house. - Add
hand Pip: 3d 3h 3c 3s 2cto the showdown. Four threes beat Dee's full house. - Change Sam's
10sto5s. He has 18 instead of going bust.
Next: Chess games replays a game from its moves; Text adventure rolls dice inside a story.
~~~ selfscribe
# Lesson: Write playing cards as short codes, and let the cards plugin deal, name and score them.
# You learn: one rule that hands a fenced block to a plugin, cards as a rank and a suit, a hold'em hand you step through, five-card hands named and ranked, blackjack totals.
# Try this: change the river from `Kh` to `2c`, and at the river Cy's four sevens win instead.
# summary: Write cards as short codes and see hands dealt, named and scored.
# category: fun
# tags: interactive, simple, social
# uses: games
use markdown
set title Card games
set heading-font Playfair Display
# ---- Colours, each with its shade for dark pages -------------------------------------
palette
felt #17694a dark #5fd39a
# ---- "~ Friday game · 13 November 2026": the line above the title ---------------------
line ~ _ -> div.kicker { font: 700 0.72em/1 var(--doc-font-ui); letter-spacing: 0.2em; text-transform: uppercase; color: var(--felt); margin-bottom: -2.4em } as pk-kicker
# ---- "```cards" … "```": the lines inside are dealt as playing cards ---------------------
# verbatim: the plugin reads the lines as written, so no other rule touches them.
block ``` cards ... ``` -> cards verbatim
~~~
~ Friday game at Ana's · 13 November 2026
# Poker night
Six players, one table, and the hand everyone was still talking about on Saturday.
```cards
title: The hand of the night
pot: 4,800
board: Ah Kd 7s | 7c | Kh
hand Ana: As Ad | slow-played the flop
hand Bo: Ks Kc | turned a full house
hand Cy: 7h 7d | flopped a set
```
Press ▶ or the arrow keys to deal the flop, the turn and the river. Each hand says what it holds so far, and at the river the winner lights up.
## Showdown practice
No board here: each player shows five cards, and the best hand is marked.
```cards
title: Which one wins?
game: poker
hand Dee: 9s 9h 9d 4c 4s
hand Eli: 2h 5h 8h Jh Kh
hand Flo: 6c 7d 8s 9c 10c
```
## Blackjack, after midnight
The dealer's cards come first. An ace counts 11 or 1, whichever keeps a hand at 21 or under.
```cards
game: blackjack
dealer: Kh 6c 5d
hand You: As 7d | stood on soft 18
hand Sam: 9c 4h 10s
hand Gus: Ac Kd
```
## Chips at the end of the night
| Player | Bought in | Left with |
|---|---:|---:|
| Ana | 2,000 | 6,350 |
| Bo | 4,000 | 1,100 |
| Cy | 2,000 | 2,900 |
| Dee | 2,000 | 1,600 |
| Eli | 2,000 | 0 |
| Flo | 2,000 | 2,050 |
Next game: Friday 27 November, at Bo's. He wants a rematch.
## How it's made
- A card is its rank and its suit: `As` is the ace of spades, `10h` the ten of hearts, `Kd` and `7c` the king of diamonds and the seven of clubs.
- Inside a `cards` block, `hand Ana:` gives a player their cards, and a `|` after them adds a note. `board:` lays the shared cards, with `|` between the flop, the turn and the river.
- `game: poker` ranks five-card hands, and `game: blackjack` counts totals. One rule in the rules block hands every `cards` block to the plugin.
## Try it yourself
1. Change the river from `Kh` to `2c`. At the river Cy's four sevens win the hand of the night.
2. In the showdown, change Eli's cards to `Ah Kh Qh Jh 10h`. A royal flush beats Dee's full house.
3. Add `hand Pip: 3d 3h 3c 3s 2c` to the showdown. Four threes beat Dee's full house.
4. Change Sam's `10s` to `5s`. He has 18 instead of going bust.
Next: *Chess games* replays a game from its moves; *Text adventure* rolls dice inside a story.