; Poker Night for HexDroid
;
; A multiplayer discord-like poker game for IRC
; data model (lists/maps) + view{} table + age.* encrypted transport
;
; the player who opens the table deals. The dealer sees every hand (it scores the showdown),
; so play with people you trust. It publishes a hash of each deck's seed at the deal and the seed
; when the hand ends, so every player can check the cards weren't changed mid-hand.
;
; only players in the channel can sit down, and leaving it (part, quit, kick, lost
; connection) takes you off the table at once. Each device also checks in every 10 s, so a phone
; that dies behind a bouncer is noticed within about a minute. Coming back within five minutes
; restores your chips.
set %rankmap $map(A,
14,K,
13,Q,
12,J,
11,T,
10,
9,
9,
8,
8,
7,
7,
6,
6,
5,
5,
4,
4,
3,
3,
2,
2)
; default avatars: a stable emoji face per player (picked from a hash of their fingerprint) so a
; seat is instantly recognisable instead of a bare initial. An uploaded photo still wins over it.
set %emojimap $map(0,🦊,
1,🐼,
2,🐵,
3,🐯,
4,🦁,
5,🐸,
6,🐙,
7,🦉,
8,🐺,
9,🐷,a,🐨,b,🐰,c,🦝,d,🐮,e,🐳,f,🦄
)
poker_reset
sidebar add poker poker_open ♠ Play Poker
}
; Full reset to a clean lobby. Used on load AND when the table is closed, so closing a game
; terminates it completely - re-opening (even on a different network) shows a fresh lobby
; instead of the previous hand.
alias poker_reset {
set %hostlocked 0 ; host decided for this table (we minted, or adopted a host's key): freeze it
set %reveal $map() ; fp->"c1 c2" of non-folded hands, populated ONLY at showdown then
set %hostfrom ; fp we accept authoritative state + STOP from (the dealer that keyed the table)
set %turnid 0 ; bumped every time the turn moves; a stale clock tick is ignored
set %actclockms 45000 ; per-turn shot-clock (ms); the host auto-checks/folds an AWOL player
set %pending $map() ; fp->name of players who joined mid-hand; seated at the next deal
set %clockleft 0 ; visual per-turn countdown (seconds), ticked locally on every node
set %clockturn 0 ; last %turnid a countdown was started for (avoids restart on re-broadcast)
set %avatar $map() ; optional fp->image-URL for player avatars; empty falls back to initials
set %evseq 0 ; host: monotonic broadcast sequence (full states AND deltas share it)
set %cliseq 0 ; client: highest broadcast sequence applied, for delta gap detection
set %resyncing 0 ; client: 1 while waiting for a full-state resync after a detected gap
set %advturn 0 ; host: poker_advance set this to 1 iff it only moved the turn (=> delta-able)
set %lastraise 0 ; size of the last full raise this round; a raise must add at least this
set %noreraise $map() ; fp->1: acted before a short all-in, so may only call or fold this round
set %minraiseto ; client: smallest legal raise-to for the seat to act (0 = may not raise)
set %strikes $map() ; host: consecutive turns a seat timed out on; two removes them
set %leaving $map() ; host: seats to remove at the next deal
set %commit ; hash of this hand's deck seed, published at the deal
set %revealseed ; host: the seed, published once the hand ends so players can check the deal
set %checkedhand ; client: the commitment whose deal we already checked
set %holefresh 0 ; client: hole cards arrived since the last new commitment
set %holehand ; client: the commitment our current hole cards were dealt under
set %hostquiet 0 ; client: watchdog ticks since the dealer was last heard
set %silent $map() ; host: presence sweeps since each player's device last checked in
set %gone $map() ; host: fp->generation for players who left and may come back in time
set %forgotten $map() ; host: players whose grace ran out; a rejoin is a fresh buy-in
set %lastact $map() ; fp->CHECK|CALL|RAISE|ALL-IN|FOLD, this street, shown on the seat
; bumping a generation stops any timer loop left over from an earlier table
}
; ---- open / join -----------------------------------------------------------
; The sidebar entry point: just (re)draw the table. Render copes with every state
; (empty lobby, seated-and-waiting, mid-hand, showdown).
alias poker_open { set %closed 0 | poker_render
}
; /poker_avatar <url> - set your own table avatar image (empty URL clears it back to your initial).
; Local to this device; others keep whatever avatar they have set for you.
alias poker_avatar {
poker_render
}
; The user tapped Close on the table → halt the bot loop so a pending timer tick can't
; re-render and pop the table straight back open.
; Closing the table properly. %closed latches FIRST so that nothing below (or any inbound state /
; delta / timer tick that lands afterwards) can re-render and pop the table straight back open.
; poker_endtable is an ALIAS, not a signal handler: a bare verb here only resolves against aliases,
; so naming a signal handler would fall through to the slash pipeline and hit the server as an
; unknown command, leaving the table running with no way to stop it.
poker_endtable
}
; Dealer ends the table: drop our queued flood first (so STOP isn't stuck behind it or dropped by the
; purge), broadcast an authenticated STOP move, then tear our own key/roster down. "Anyone can re-open"
; falls out naturally: once everyone has torn down, normal election lets any player open a fresh table.
; A non-dealer just leaves quietly. Defined as an alias so it is callable as a plain verb (buttons
; raise SIGNALs, so the button is wired through the thin handler below).
alias poker_endtable {
if (%practice == 1) { poker_reset
| return }
if (%ishost == 1 && %hosted == 1) {
age.purge %chan ; discard the paced-out state-broadcast backlog while we still hold K_G
age.send %chan stop
; authenticated, members-only STOP into the now-drained queue
age.close %chan ; drop key/roster locally. NOT a purge, so the queued STOP still goes out
poker_reset
}
poker_teardown ; not actually the dealer: just leave and clean up
}
; The header "End Table" button (buttons raise SIGNAL:<name>). Ends the table and redraws the lobby;
; the redraw is a no-op when this arrived via a closed view, because poker_render honours %closed.
poker_endtable
poker_render
}
; We received the dealer's STOP: drop our own queued flood and tear down.
alias poker_onstop {
toast The dealer ended the table
poker_teardown
poker_render ; drop back to the lobby (no-op if we already closed the view)
}
; Local teardown shared by every close path: purge any of our queued AGE for this table, drop the
; key/roster/announce state in the bridge (age.close), then reset the game model. age.close is a no-op
; in practice. Order: purge before close so nothing for this channel is left trickling out.
alias poker_teardown {
poker_reset
}
alias poker {
; Practice runs entirely on the local loopback (#practice is never an IRC channel).
; A real game must actually be in the shared IRC channel so peers can exchange +AGE lines.
if (%practice == 0) { join %chan }
age.join %chan ; announce our +AGE identity (real: broadcast; practice: skipped)
age.send %chan join
$age.me $me 1000 ; register me (local always; to peers once the host has keyed)
if (%practice == 0) { toast Joined
%chan, waiting for the host to start the hand
}
else { toast Joined the table - waiting for players
}
}
; lobby buttons
on SIGNAL:
poker_join { poker
}
if (%practice == 1) { poker_deal
| return }
; The player who taps Open HOSTS the table. Host is decided by action, never by fingerprint order:
; electing the lowest fingerprint made the tapper stand down whenever it wasn't the lowest, while
; the elected owner's device sat showing an Open button nobody tapped - so nobody minted and both
; sides waited forever. If two players tap at the same moment both mint, and the bridge converges
; on the lower fingerprint's key (invite authorisation); the loser adopts it via age_ready and
; stops being host. Once a host exists (%hostlocked) it never changes for the life of the table.
if (%hostlocked == 1 && %ishost == 0) { toast Waiting for the host to start the hand
| return }
if (%hosted == 0) { poker_host
| return }
poker_deal
}
; Mint the shared table key and lock ourselves in as host for the life of this table.
alias poker_host {
timer 15000 poker_hb
%hbgen
poker_render
toast Table keyed. Players are joining
; tap Deal when ready
}
; Dealer heartbeat, so players can tell a quiet table from a dealer who has gone.
poker_sweeppresence
timer 15000 poker_hb
%hbgen
}
; Player watchdog: a dealer silent for about a minute (no state, move or heartbeat) has left, and
; the table can't continue without it.
alias poker_watchstart {
timer 10000 poker_watch
%watchgen
}
set %hostquiet $calc(%hostquiet +
1)
toast The dealer stopped responding, so the table has ended
poker_teardown
poker_render
}
timer 10000 poker_watch
%watchgen
}
; a +AGE peer announced on $chan: refresh the lobby so a new arrival shows up. Host election is not
; re-run here - the host is whoever opened the table, and %hostlocked freezes it.
poker_render
}
; the shared table key just arrived: we are a CLIENT, not the host (a host mints its own key and
; never receives an invite). This also covers losing a simultaneous-open race: we minted, the peer's
; lower-fingerprint key won, and we adopt it and stop hosting. Register at the table over the
; now-encrypted channel so the host sees us seated.
}
; $from = sender fp ; $1 = move type ; $2- = payload
; Host-authoritative: the dealer runs all game logic and broadcasts state; clients render it.
if ($1 == join
) { poker_onjoin
$1 $2 $3 $4 }
elseif ($1 == act
) { if (%ishost == 1) { poker_onact
$1 $2 $3 } }
elseif ($1 == state
) { if ($from != %me) { set %hostfrom $from | set %hostquiet 0 | poker_watchstart
| poker_applystate
$2- } }
; Pass the delta's tokens through INDIVIDUALLY. `$3-` would arrive as a single joined argument
; (that is what `poker_applystate $2-` wants for its JSON blob), so the alias would see the whole
; rest of the line as $2 and never match "act": the delta was silently dropped and the client sat
; on a stale turn. Tokens: ev seq act fp bet stack fold allin pot tocall turn turnid.
elseif ($1 == ev
) { if ($from != %me) { set %hostfrom $from | set %hostquiet 0 | poker_onev
$2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 } }
elseif ($1 == sync
) { if (%ishost == 1 && $from != %me) { poker_broadcast
} } ; a client missed a delta; resend full state
; the dealer ended the table. Honour STOP only from the authenticated host we've been following
; (the signature already proves $from; this stops a non-dealer member from nuking the table), and
; never from our own local echo (the sender tears down in poker_stop instead).
if ($from != %me && $from == %hostfrom) { poker_onstop
}
}
}
; Someone left the game channel: part, quit, kick, or our own connection dropping ($from is then us).
}
; $1 = the fingerprint that left. We left: tear down. The dealer left: the table ends. As dealer:
; take the player off the table now, keeping their chips for the grace period in case they return.
alias poker_onleft {
if (%hostlocked == 1) { toast You left the table
}
poker_teardown
poker_render
}
toast The dealer left, so the table has ended
poker_teardown
poker_render
}
}
if ($has(%seats,
%lfp) == true) { set %seatedl 1 }
if ($get(%pending,
%lfp) == 1) { set %seatedl 1 }
; keep their chips for five minutes; poker_forget releases them after that
setat %gone %lfp %gonegen
timer 300000 poker_forget
%lfp %gonegen
; In a hand: fold them, unless they're all-in, whose chips are committed and play to showdown.
if ($has(%seats,
%lfp) == true) { if ($get(%folded,
%lfp) != 1) { if ($get(%allin,
%lfp) != 1) {
poker_checkfoldout
}
} } }
poker_removeleavers
}
poker_broadcast
poker_render
}
; Host: a fold outside the player's turn can leave one player standing, who wins at once.
alias poker_checkfoldout {
if (%live < 2) { poker_endhand
%onlyfp }
}
; A departed player's grace ran out ($1 fp, $2 generation): their chips are released, so coming
; back later is a fresh buy-in.
}
; Host: take the seats marked in %leaving off the table. The button stays with the same player
; where it can; if they left, the next deal's button move lands on whoever sat after them.
alias poker_removeleavers {
set %btnfp $get(%seats,
%button)
}
; Host presence sweep, every heartbeat: a player's device checks in every 10 s, so one silent for
; four sweeps (about a minute) is gone even if IRC still shows them, as behind a bouncer.
alias poker_sweeppresence {
foreach %fp %seats { poker_tickpresence
%fp }
foreach %fp $keys(%pending) { if ($get(%pending,
%fp) == 1) { poker_tickpresence
%fp } }
foreach %qfp %quietfps { poker_onleft
%qfp }
}
alias poker_tickpresence {
if (%sil >= 4) { push %quietfps $1 }
}
; ---- host-authoritative state sync -----------------------------------------
alias poker_sethost {
; Host is decided by ACTION (who tapped Open), not by fingerprint order. %hostlocked is set when we
; mint (poker_host) or when we adopt a host's key (age_ready), and from then on the host is fixed
; for the life of the table - a later joiner can never steal authority mid-hand. Before any table
; exists nobody is host yet, and anyone may open one.
}
; ---- seat helpers: find the next seat still in the hand / able to act ----------
; A busted or folded seat is skipped. These use locals (set -l) so they never clobber
; a caller's %n/%fp/%idx while it is mid-loop.
alias poker_nextin {
; $1 = start index; returns the next index (wrapping) whose seat isn't folded/busted
}
}
alias poker_nextactor {
; $1 = start index; returns the next index (wrapping) that can still act (not folded, not all-in)
}
}
alias poker_broadcast {
set %evseq $calc(%evseq +
1) ; full states and deltas share one monotonic sequence (carried as q)
; Compact wire state (age_msg reassembles tokens with $2-, single spaces; keep names free of
; double spaces). Per-player fields are arrays ALIGNED TO %seats (each fp once, not repeated as
; map keys); top-level keys are single letters; default/empty fields are omitted so a mid-hand
; update usually fits ONE AGE line. Key legend (mirrored in poker_applystate):
; s=seats n=names k=stacks b=bets f=folded a=allin d=board r=reveal p=pot c=tocall
; t=turn e=street y=started u=button g=turnid w=winner o=gameover h=champion
}
if (%hasrev == 1) { setat %st r
%aR } ; only at showdown; mid-hand it is all mucked
setat %st q
%evseq ; sequence baseline so clients can gap-check deltas
if (%started == 1) { setat %st m
$poker_minraise } ; smallest legal raise-to for the seat to act
if ($len(%commit) > 0) { setat %st z
%commit } ; this hand's deck commitment
if (%started == 0) { if ($len(%revealseed) > 0) { setat %st x
%revealseed } } ; its seed, once over
if ($len(%winnertext) > 0) { setat %st w
%winnertext } ; only on a result
if (%gameover == 1) { setat %st o
1 } ; only when the table has ended
if ($len(%champion) > 0) { setat %st h
%champion }
}
; Host: broadcast just the fields an in-street action changes, as ONE short line (no FRAG), instead of
; the whole table. $1 = the acting fp. A dropped delta is caught by the sequence gap check in
; poker_onev and healed with a full-state resync, so this stays lossless.
alias poker_evact {
if ($get(%folded,
$1) == 1) { set %efd 1 }
if ($get(%allin,
$1) == 1) { set %eai 1 }
age.send %chan ev
%evseq act
$1 $get(%bet,
$1) $get(%stack,
$1) %efd %eai %pot %tocall %turn %turnid $poker_minraise
}
; The smallest legal raise-to for the seat to act, or 0 when it may only call or fold.
alias poker_minraise {
set -l %cur $get(%seats,
%turn)
}
; Client: apply an inbound delta. Called as poker_onev <seq> <type> <payload...>. Enforces contiguity
; against %cliseq; a gap means we missed a delta, so ask the host once for a full resync and ignore
; further deltas until it lands (poker_applystate clears %resyncing).
alias poker_onev {
if (%ishost == 1) { return } ; the host is authoritative; it never applies deltas
if (%eseq <= %cliseq) { return } ; stale / duplicate
if (%eseq > $calc(%cliseq +
1)) {
}
if ($2 == act
) { poker_ev_act
$3 $4 $5 $6 $7 $8 $9 $10 $11 $12 }
poker_startclock
poker_render
}
; Apply an act delta: $1 fp $2 bet $3 stack $4 fold $5 allin $6 pot $7 tocall $8 turn $9 turnid
; $10 min raise-to (absent from older dealers). folded/allin only latch on, matching poker_applystate.
alias poker_ev_act {
if ($4 == 1) { setat %folded $1 1 }
setat %lastact $1 $poker_actlabel($1,
%betbefore,
%callbefore)
}
; What seat $1 just did, from its bet before ($2) and the amount to call before ($3).
alias poker_actlabel {
}
alias poker_applystate {
}
}
; per-player fields arrive as arrays aligned to %seats (see poker_broadcast); zip them by index.
if (%fd == 1) { setat %folded %fp 1 }
if (%ai == 1) { setat %allin %fp 1 }
}
if (%street != %laststreet) { set %lastact $map() | set %laststreet %street }
; A new commitment starts a new hand. Our sealed cards arrive just before its first state, so
; only cards received since the previous commitment belong to it.
if ($len(%zv) > 0) { if (%zv != %commit) {
if (%holefresh == 1) { set %holehand %zv }
} }
if ($len(%xv) > 0) { if (%checkedhand != %commit) { poker_checkdeal
%xv } }
; A full state is an authoritative resync point: adopt its sequence baseline and clear any pending
; gap so subsequent deltas are measured from here.
; winner/gameover/champion are omitted from the wire unless set, so a missing field restores to
; empty / 0 ("not over", no banner) - correct for a live hand.
if ($len(%gameover) == 0) { set %gameover 0 }
poker_sethost
poker_startclock
poker_render
}
alias poker_onjoin {
; $2 = fp, $3 = name, $4 = stack
; track roster as a map fp->name and an ordered list (idempotent on rejoin). A brand-new player
; who arrives mid-hand is parked in %pending and seated at the next deal, so a join never
; renumbers %seats or shifts the turn pointer inside a live hand.
; Only players present in the channel may sit down. $age.members lists the +AGE peers here now;
; an empty list (nobody announced yet, or an older app) doesn't block anyone.
} }
if ($has(%name,
$2) == false) { set %newp 1 }
if ($get(%forgotten,
$2) == 1) { set %newp 1 | setat %forgotten $2 0 }
; the buy-in stack in $4 applies to NEW players only. A join from a player we already know is a
; REJOIN (left and came back, app restart, or a re-invite echo), and overwriting their live stack
; with the buy-in both breaks chip conservation mid-hand and hands anyone a free refill exploit:
; leave the table, rejoin, and your losses are erased. Returning players keep their chips.
if (%newp == 1) { setat %stack $2 $4 }
; seat anyone not seated or waiting: new players, and players removed for being away
if ($has(%seats,
$2) == false) { if ($get(%pending,
$2) != 1) {
if (%started == 1) { setat %pending $2 1 }
} }
poker_sethost
if (%ishost == 1) { poker_broadcast
}
poker_render
}
; ---- practice mode: play a full hand solo against calling-station bots --------
alias poker_practice {
poker
poker_deal
}
; bot turn-driver - runs on a scheduled tick (NOT synchronously) so the main thread
; is never blocked by a long cascade of bot actions; each tick acts once, the UI
; repaints, then the next action is re-scheduled by poker_onact / poker_deal below.
if ($has(%bots,
%cur) == true) { poker_botbrain
%cur }
}
}
}
; Arm the per-turn shot clock. Bumps %turnid so a tick scheduled for an earlier turn is ignored
; once the turn moves on. In real games the host schedules itself to auto-act if the seat to move
; goes quiet (disconnected or just away), so one absent player can never freeze the whole table.
; Bots run on their own fast driver (poker_botstep), so this only ever resolves a human who left.
alias poker_armclock {
; %turnid is bumped by the turn-setters (postblinds/advance/firstact), so it already reflects the
; turn being armed here. This only (re)arms the host timeout and the local countdown; being called
; more than once for the same turn is harmless (same turnid, idempotent countdown).
if (%practice == 0) { if (%ishost == 1) { timer %actclockms poker_turntimeout
%turnid } }
poker_startclock
}
; Local visual countdown (host and every client). It just ticks a per-turn number down once a
; second and repaints; the host's poker_turntimeout is what actually acts when it hits zero.
; Keyed on %turnid so a new turn restarts it and a stale tick from a finished turn is ignored.
alias poker_startclock {
timer 1000 poker_clocktick
%turnid
}
set %clockleft $calc(%clockleft -
1)
if (%clockleft < 0) { set %clockleft 0 }
poker_render
if (%clockleft > 0) { timer 1000 poker_clocktick
%turnid }
}
if ($1 != %turnid) { return } ; the turn already moved on; stale tick
if ($has(%bots,
%cur) == true) { return } ; bots resolve themselves
; auto-act for the away seat: check when it costs nothing, otherwise fold. age.local injects the
; move locally as that seat (exactly like a bot move) and the host re-broadcasts the result.
; A second missed turn in a row folds them and removes them at the next deal; they can rejoin.
toast $get(%name,
%cur) is away and will leave the table after this hand
}
setat %strikes %cur %strk
}
; A simple but believable bot: folds trash, calls/raises by hand strength, bluffs occasionally.
; Pre-flop it scores the two hole cards; post-flop it uses the made-hand category (0..7). Pot odds
; make cheap calls more tempting, and a random roll keeps it from being predictable. Two named
; practice bots have distinct styles so solo play isn't monotonous: Botcall (bot1) is a loose-
; passive calling station (calls very wide, almost never raises or bluffs) and Robofish (bot2) is a
; loose-aggressive maniac (raises a wide range, bluffs often). Any other bot uses the middle profile.
; Approximate drawing outs to a flush or straight for $1- (hole + board), 0 if a straight is
; already made or there is no draw. Flush draw (exactly 4 of a suit) ~ 9 outs; open-ended straight
; draw (2+ ranks complete a straight) ~ 8; gutshot (exactly 1) ~ 4. Used post-flop so the bot can
; semi-bluff and call the right price on draws instead of folding every unmade hand.
alias poker_outs {
}
}
}
if (%compl >= 2) { set -l %outs $calc(%outs +
8) }
}
}
alias poker_botbrain {
if (%need < 0) { set %need 0 }
; ---- personality knobs (kept as flat conditions; grouping like (A || B) && C also works now) ----
set %callpf 19 ; pre-flop score needed to call a bet
set %raisepf 26 ; pre-flop score needed to raise
set %bluff 6 ; roll cutoff for a pure bluff (higher = bluffs more)
set %aggr 50 ; roll cutoff for value-raising a marginal made hand
set %stationcall 0 ; 1 = call down light rather than fold
set %rmult 3 ; raise size in big blinds
if (%bot == bot1
) { set %callpf 12 | set %raisepf 34 | set %bluff 0 | set %aggr 15 | set %stationcall 1 }
if (%bot == bot2
) { set %callpf 16 | set %raisepf 20 | set %bluff 35 | set %aggr 80 | set %rmult 4 }
if (%aggr2 < 0) { set %aggr2 0 }
; raise target = current call level + N big blinds, capped at all-in
if (%raiseto > %maxto) { set %raiseto %maxto }
; a call is "cheap" when it costs a quarter of the pot or less
if (%need <= %cheapthresh) { set %cheap 1 }
; pot odds: the price of a call as a percentage of the pot after we put the chips in. A flush/OESD
; (~8-9 outs) is roughly a 1-in-3 shot with two cards to come, so calling is right up to ~33%.
if (%denom > 0) { set %price $int($calc(%need *
100 /
%denom)) }
; ---- pre-flop: score the two hole cards (high cards + pair/suited bonuses) ----
; split on the default (space) delimiter; $split(x, " ") works too now that quoted args
; are string literals, but the bare form stays the simplest spelling.
if (%pf >= %raisepf) { age.local %bot act raise
%raiseto }
if (%pf >= %raisepf) { age.local %bot act raise
%raiseto }
}
; ---- post-flop: made-hand category 0=high .. 7=quads ----
set %sc $poker_handscore($get(%hole,
%bot) $join(%board))
; drawing outs, but only while a card is still to come (turn/river); on the river a draw is dead
if ($len(%board) < 5) { set %outs $poker_outs($get(%hole,
%bot) $join(%board)) }
if (%outs >= 8) { set %strongdraw 1 }
elseif (%strongdraw == 1 && %roll < %aggr) { age.local %bot act raise
%raiseto }
elseif (%strongdraw == 1 && %cheap == 1 && %roll < %aggr2) { age.local %bot act raise
%raiseto }
}
}
}
; ---- start a hand (dealer button rotates each hand) ------------------------
alias poker_deal {
poker_sethost
; take off players who left or timed out twice
poker_removeleavers
; seat anyone who joined during the previous hand (parked in %pending), now that seat order and
; the turn pointer can safely change. Guard against double-seating on a rejoin.
toast Not enough players left to deal
poker_broadcast
poker_render
}
set %reveal $map() ; last hand's shown cards clear so they don't linger into the new deal
; players with no chips are out for the hand: mark them folded so every downstream loop
; (turn advance, showdown, live-count) skips them with no special-casing.
; move the dealer button to the next player who still has chips (first hand keeps seat 0)
if (%handid > 0) { set %button $poker_nextin($calc(%button +
1)) }
set %dealerfp $get(%seats,
%button)
; Shuffle from a private seed and publish a hash of it now; the seed follows when the hand ends,
; so players can check the deal (poker_checkdeal). It doesn't stop the dealer seeing the cards.
poker_builddeck
; deal 2 hole cards per seat; only seal to players actually in the hand
if (%ishost == 1) { setat %hole %fp %c1 %c2 }
}
; community sits after all hole cards
; post blinds relative to the button and open betting
poker_postblinds
poker_render
poker_broadcast
poker_armclock
}
alias poker_builddeck {
foreach %r $list(2,
3,
4,
5,
6,
7,
8,
9,T,J,Q,K,A
) {
; keyed shuffle: sort cards by a PRF of (seed, card) - a verifiable permutation
}
}
}
}
alias poker_postblinds {
; how many players are actually in this hand (chips at the start)
; blind seats relative to the button, skipping busted players
; heads-up: the button posts the small blind and acts first pre-flop
set %bbi $poker_nextin($calc(%button +
1))
set %sbi $poker_nextin($calc(%button +
1))
set %bbi $poker_nextin($calc(%sbi +
1))
}
; post blinds, clamped to stack (a short stack goes all-in on its blind)
if (%sbamt > $get(%stack,
%sbfp)) { set %sbamt $get(%stack,
%sbfp) }
if (%bbamt > $get(%stack,
%bbfp)) { set %bbamt $get(%stack,
%bbfp) }
setat %contrib %sbfp %sbamt
setat %contrib %bbfp %bbamt
if ($get(%stack,
%sbfp) <= 0) { setat %allin %sbfp 1 }
if ($get(%stack,
%bbfp) <= 0) { setat %allin %bbfp 1 }
; first to act pre-flop = next player who can act after the big blind (heads-up: the SB/button)
if (%inhand < 3) { set %turn %sbi }
}
; our sealed hole cards arrive here
; $data = "<c1> <c2>"
poker_render
}
; ---- betting ---------------------------------------------------------------
on SIGNAL:
poker_min { set %betamount 0 | poker_render
}
on SIGNAL:
poker_q { poker_presize
1 4 }
on SIGNAL:
poker_h { poker_presize
1 2 }
on SIGNAL:
poker_pot { poker_presize
1 1 }
on SIGNAL:
poker_t { poker_presize
3 4 }
; Raise to the current bet plus $1/$2 of the pot after calling (a "pot" raise is the standard one);
; poker_render then clamps it between the minimum raise and all-in.
alias poker_presize {
if (%pneed < 0) { set %pneed 0 }
poker_render
}
on SIGNAL:
poker_allin { set %betamount 999999999 | poker_render
}
on SIGNAL:
poker_dec { set %betamount $calc(%betamount -
%bb) | poker_render
}
on SIGNAL:
poker_inc { set %betamount $calc(%betamount +
%bb) | poker_render
}
alias poker_onact {
; Drop stale / double-tapped / out-of-turn actions. The view only shows action buttons on
; your turn, but taps can still race the async re-render; without this guard a second tap
; re-applies a move for a seat that has already acted, corrupting stacks/pot and the turn
; pointer (the "mash the buttons" crash). Only the seat whose turn it is may act.
; $from acted: $2 = fold|check|call|raise ; $3 = raise-to amount
}
elseif ($2 == raise
) { poker_raiseto
%fp $3 }
elseif ($2 == allin
) { poker_raiseto
%fp all
}
; call or check (call short-stack = all-in for the rest)
if (%need < 0) { set %need 0 }
if (%put > $get(%stack,
%fp)) { set %put $get(%stack,
%fp) }
}
setat %lastact %fp $poker_actlabel(%fp,
%betbefore,
%callbefore)
poker_advance
poker_render
; A plain in-street action only moved the turn: push a one-line delta (no FRAG) instead of the whole
; table. Street changes / hand ends fall through to a full state (poker_nextstreet/endhand paths).
if (%advturn == 1) { poker_evact
%fp } else { poker_broadcast
}
poker_armclock
}
; Host: $1 raises to $2, or goes all-in when $2 is "all". A raise must reach the current bet plus the
; last full raise (at least the big blind); a smaller one is lifted to that minimum, and a player who
; can't cover it goes all-in. Only a full raise reopens the betting: after a short all-in, players
; who already acted may call or fold but not raise again. A raise from such a player is a call.
alias poker_raiseto {
if ($get(%noreraise,
%fp) == 1) { set %rto %tocall }
set %rmin $calc(%tocall +
%lastraise)
if (%rto < %rmin) { set %rto %rmin }
}
if (%rto > %rmax) { set %rto %rmax }
if (%put < 0) { set %put 0 }
set %raiseby $calc(%newbet -
%tocall)
if (%raiseby >= %lastraise) {
}
}
}
alias poker_endhand {
; $1 = sole survivor fp - everyone else folded; wins the whole pot
set %winnertext $get(%name,
$1) wins
%pot
set %pot 0 ; pot is now in the survivor's stack; clear it for the lobby
poker_checkover
poker_broadcast ; push the final stacks, pot=0 and winner line to every client
poker_render
}
; End-of-session check: if one player (or none) has chips left, the game is over and the
; last player standing is the champion. Call after a hand's chips have been paid out.
;
; Robust champion selection: the winner is the seat holding the most chips, which is by
; definition the sole survivor once everyone else has busted to 0. Deriving it from the max
; stack (rather than "the last seat we saw with a positive stack") means we never emit an
; empty champion - the bug behind the reported "<empty> wins the table" banner, which happened
; whenever the survivor-tracking loop finished with no positive-stack seat recorded (e.g. an
; all-in showdown edge where the pot had not yet landed in a stack when this ran). We only
; declare the game over when there IS a named survivor; a seatless/blank table is left alone.
alias poker_checkover {
if (%stk > 0) { set %alive $calc(%alive +
1) }
if (%stk > %topstk) { set %topstk %stk | set %topfp %fp }
}
set %champname $get(%name,
%topfp)
if ($len(%champname) > 0) {
}
}
}
}
alias poker_advance {
; last player standing wins immediately
poker_endhand %onlyfp
; round closes when every non-folded, non-all-in player has acted AND matched %tocall
if ($get(%folded,
%fp) != 1) { if ($get(%allin,
%fp) != 1) {
if ($get(%acted,
%fp) != 1) { set %open 1 }
if ($get(%bet,
%fp) != %tocall) { set %open 1 }
} }
}
poker_nextstreet
; advance to the next seat that can act (non-folded, non-all-in)
if ($get(%folded,
%cur) != 1) { if ($get(%allin,
%cur) != 1) { set %done 1 } }
}
}
}
}
}
alias poker_firstact {
; first to act after the flop = first player who can act to the left of the button
set %turn $poker_nextactor($calc(%button +
1))
}
alias poker_nextstreet {
poker_showdown
; dealer reveals the next board card(s) from its deck
if (%street == preflop
) { set %street flop
| poker_reveal
3 }
elseif (%street == flop
) { set %street turn
| poker_reveal
1 }
elseif (%street == turn
) { set %street river
| poker_reveal
1 }
poker_firstact
; if fewer than two players can still act (rest all-in/folded), run the board out
if (%actors < 2) { poker_nextstreet
}
else { timer 350 poker_botstep
| poker_armclock
} ; re-arm the bot loop: a new street can open on a bot's turn
}
}
; Client: check the finished hand against the dealer's commitment. $1 = the revealed seed. Its hash
; must match the commitment published at the deal, and the deck it builds must hold our own hole
; cards and the board where the deal puts them.
alias poker_checkdeal {
poker_builddeck
if (%mi >= 0) { if (%holehand == %commit) {
} }
}
}
if (%dealok == 0) { toast Warning: this hand's cards don't match the deck the dealer committed to
}
}
alias poker_reveal {
; $1 = count. dealer pulls from %deck at %base and broadcasts.
}
}
; ---- hand evaluation (value function - returns a sortable score) ----
; Hand evaluation. Scores the BEST 5-card poker hand from the 5-7 cards in $1-.
; Category is the leading base-15 digit, high to low: 8 straight flush (incl.
; royal = ace-high), 7 four of a kind, 6 full house, 5 flush, 4 straight,
; 3 trips, 2 two pair, 1 pair, 0 high card. The five base-15 digits below the
; category are the CORRECT tiebreak ranks for that category (the flush's own
; five cards, the straight's high card, a pair's kickers, ...), so equal
; categories compare exactly as real poker does. Aces play high everywhere and
; also low for the wheel (A-2-3-4-5); a straight flush beats quads; and 7-card
; flush/straight scoring uses the actual five cards, never stray kickers.
alias poker_handscore {
}
; flush suit = the (at most one) suit holding 5+ cards
; the flush cards' ranks (distinct within a suit), high to low
}
; best straight high card (wheel-aware): among all ranks, and within the flush suit
if ($len(%flushranks) > 0) { set %sfhi $poker_straighthi($join(%flushranks)) }
; count buckets: highest quad rank; trips and pairs-or-better, each high to low
if (%c > 3) { if (%k > %quad) { set %quad %k } }
if (%c == 3) { push %trips %k }
if (%c > 1) { push %pairs %k } ; a trip also serves as a pair (full house / two pair)
}
; full house = a trip plus any OTHER paired rank (a second trip counts as that pair)
foreach %pk %pairs { if (%fhpair == 0) { if (%pk != %fhtrip) { set %fhpair %pk } } }
}
if (%fhtrip > 0) { if (%fhpair > 0) { set %isfh 1 } }
; ---- category + its tiebreak ranks (%tb, most significant first) ----
}
; ---- pack: category, then five base-15 tiebreak digits (zero-padded) ----
}
; Best straight high card from a space-separated list of rank values; 0 if none.
; Wheel-aware: an ace (14) also fills the low end so A-2-3-4-5 scores as a 5-high straight.
alias poker_straighthi {
}
}
; hand category NAME for the rank badge (derived from the score: category is the
; leading base-15 digit floor(score / 15^5); the next digit is the straight-flush
; high card, so an ace-high straight flush reads as ROYAL FLUSH).
alias poker_handcat {
set %sc $poker_handscore($1-)
}
}
alias poker_showdown {
; score every non-folded hand (best 5 of hole+board)
if ($get(%folded,
%fp) != 1) { setat %score %fp $poker_handscore($get(%hole,
%fp) $join(%board)) }
}
; reveal every non-folded hand so the showdown is visible on EVERY client, not just the host
; (hole cards are otherwise host-only and never broadcast). Folded hands stay mucked.
; distinct sorted contribution levels define the side-pot layers
set %awarded $map() ; name -> chips actually won, so the banner can show each amount
; this layer = (lv - prevlv) chips from every player who put in at least lv
; best eligible (non-folded, contributed into this layer) score
if ($get(%folded,
%fp) != 1) { if ($get(%contrib,
%fp) >= %lv) {
if ($get(%score,
%fp) > %bsc) { set %bsc $get(%score,
%fp) }
} }
}
; split this layer among all eligible players tied at the best score
if ($get(%folded,
%fp) != 1) { if ($get(%contrib,
%fp) >= %lv) {
if ($get(%score,
%fp) == %bsc) { set %nwin $calc(%nwin +
1) }
} }
}
; integer chips only: floor the share and hand the odd chip(s) to the earliest eligible
; seats in seat order. This keeps a split pot whole (no fractional stacks, nothing created
; or destroyed): share*nwin + remainder == layer.
if ($get(%folded,
%fp) != 1) { if ($get(%contrib,
%fp) >= %lv) {
if ($get(%score,
%fp) == %bsc) {
if ($has(%winners,
$get(%name,
%fp)) == false) { push %winners $get(%name,
%fp) }
}
} }
}
; no eligible (non-folded) player reached this layer - eg an uncalled over-bet whose bettor
; then folded. Those chips belong to nobody at showdown, so return each contributor's share
; of THIS layer to them rather than letting it vanish. width chips came from each of the
; %cnt contributors, so refund width to each: width*cnt == layer, chips stay conserved.
}
}
}
; announce from who actually took chips and how much. One winner reads "Alice wins 150"; a
; genuine split or several SEPARATE side pots each show their own amount ("Alice 150, Bob 300"),
; so the banner never claims one wrong combined total. Guard the zero-winner case (every layer
; refunded) by falling back to the top-stack seat, who holds the chips.
if ($len(%winners) == 0) {
foreach %fp %seats { if ($get(%stack,
%fp) > %fbstk) { set %fbstk $get(%stack,
%fp) | set %fallbackfp %fp } }
set %winnertext $get(%name,
%fallbackfp) wins
%pot
}
set %winnertext %w0 wins
$get(%awarded,
%w0)
set %seg %wn $get(%awarded,
%wn)
if ($len(%wnames) == 0) { set %wnames %seg } else { set %wnames %wnames,
%seg }
}
set %winnertext pot:
%wnames
}
set %pot 0 ; chips are now in the winners' stacks; clear the pot for the lobby
poker_checkover
poker_broadcast ; push the final stacks, pot=0 and winner line to every client
poker_render
}
; %winnertext is the formatted result: one winner ("Eck wins 140") or a split
; ("split pot: Eck, Ada (140)"); %winners lists the names. The table banner shows the
; same text. Add a personal note when you're among the winners.
if ($has(%winners,
$get(%name,
%me)) == true) { echo %chan *** you're in the money -
%winnertext }
echo %chan *** game over -
%champion takes the table
; keep a practice session flowing: auto-deal the next hand after a short pause
if (%practice == 1) { timer 2500 poker_next
}
}
}
; Deal the next hand of an ongoing session (host-driven in a real game; auto in practice).
if (%practice == 1) { poker_deal
}
}
; Start a fresh session: reset every seated player's stack and deal hand 1 again.
poker_sethost
if (%ishost == 0) { toast Only the host can start a new game
| return }
poker_deal
}
; ============================================================================
; the table view
; The view DSL supports if/elseif/else + foreach, so the table is state-aware.
; Multi-word dynamic text is quoted ("…") so it survives as a single label.
; ============================================================================
; The host fires this when the device rotates while our view is mounted: re-render so the
; table swaps between the portrait stadium and the landscape/TV ring immediately instead of
; waiting for the next game action to repaint. Guard on %closed == 0 exactly: unset (never
; opened) expands to "", so a rotation before the first poker_open cannot pop the table, and
; poker_render's own %closed == 1 latch covers the closed-with-X case.
if (%closed == 0) { poker_render
}
}
alias poker_render {
; The table was closed with the X. Inbound state/deltas, clock ticks and bot steps all render, so
; without this latch any of them would pop the table straight back open. Re-opening from the
; sidebar (poker_open) clears it.
if ($has(%name,
%me) == true) { set %seated 1 }
set %turnfp $get(%seats,
%turn)
; dealer button follows the rotating button; blinds were set for real by poker_postblinds,
; so only derive a preview for the lobby (no hand in progress yet).
set %dealerfp $get(%seats,
%button)
set %sbi $poker_nextin($calc(%button +
1))
set %bbfp $get(%seats,
$poker_nextin($calc(%sbi +
1)))
}
; ---- action context (decide here; the view only reads flags/labels) ----
if (%started == 1) { set %active 1 }
if (%active == 1) { if (%turnfp == %me) { if ($get(%folded,
%me) != 1) { set %ismyturn 1 } } }
if (%need < 0) { set %need 0 }
if (%need > 0) { set %calllabel Call
%need }
if (%need > 0) { if (%need >= %mystack) { set %calllabel All-in
%mystack } }
; folding when a check is free is never right, so offer Fold only when there's a bet to face
if (%need > 0) { set %canfold 1 }
set %tocalllabel Check is free
if (%need > 0) { set %tocalllabel To call
%need }
; raise bounds: at least the minimum raise (the dealer's figure, or bet + big blind from an older
; dealer), at most all-in; no raise when the dealer says this seat may only call
if (%ishost == 1) { if (%started == 1) { set %rminme $poker_minraise } }
if ($len(%rminme) == 0) { set %rminme $calc(%tocall +
%bb) }
if (%rminme == 0) { set %canraise 0 }
if (%rmaxme <= %tocall) { set %canraise 0 }
if (%betamount < %rminme) { set %betamount %rminme }
if (%betamount > %rmaxme) { set %betamount %rmaxme }
set %raiselabel Raise to
%betamount
if (%betamount >= %rmaxme) { set %raiselabel All-in
%rmaxme }
; Host action gating. Keying the table (age.host) only needs the host seated - a lone host must be
; able to open the table so peers can join encrypted; dealing a hand needs at least two seats. So
; canstart is true for the host in the lobby when either the table is not yet keyed (open it) or it
; is keyed and enough players are seated (deal). Without the pre-key case a solo host could never
; open the table and real multiplayer would deadlock, showing "Join Table" again after joining.
; Host action gating. Before any table exists nobody is host yet, so ANY seated player may open one
; (whoever taps becomes the host). Gating this on %ishost was the no-host deadlock: with the host
; elected by fingerprint, the tapper wasn't allowed to open and the elected owner never tapped.
; Once a table is keyed, only its host may deal, and only with enough players seated.
if (%active == 0 && %gameover == 0) {
if (%hostlocked == 0) { set %canstart 1 }
elseif (%ishost == 1 && %hosted == 1 && %nseat > 1) { set %canstart 1 }
}
set %startlabel Open Table
if (%hosted == 1) { set %startlabel Deal Hand
}
if (%handid > 0) { set %startlabel Next Hand
}
set %hostlabel Start a table
if (%hosted == 1) { set %hostlabel You're the host
}
; The dealer can end the table whenever it is keyed: mid-hand, at showdown, or while waiting in
; the lobby. Gating this on the lobby-only %canstart made End Table useless exactly when a stuck
; table needs ending, so it lives in the header and is driven by its own flag.
if (%practice == 0 && %ishost == 1 && %hosted == 1) { set %canend 1 }
; A player seated in the lobby who can't act yet (a non-host waiting on the host, or the host who
; has opened the table and is waiting for players) gets a status line - never the "Join Table"
; button again, which reads as though their join silently failed.
set %seatwait Waiting for the host to start the hand
if (%ishost == 1) { set %seatwait Table open · waiting for players to join
}
; game over: one player has all the chips
if (%gameover == 1) { set %isover 1 }
if (%isover == 1) { if (%ishost == 1) { set %cannewgame 1 } }
set %overlabel %champion wins the table
if ($len(%champion) == 0) { set %overlabel Game over
}
if (%active == 1) { if (%ismyturn == 0) { set %waiting 1 } }
set %waitlabel Waiting for
$get(%name,
%turnfp)…
; per-turn shot-clock label (blank unless a live hand is counting down)
if (%active == 1) { if (%clockleft > 0) { set %clocklabel ⏱
%clockleft s
} }
; shot-clock bar: filled part is time left, turning red for the last ten seconds
if (%clockw1 <= 0) { set %clockw1 0.01 }
set %clockw2 $calc(%clocktotal -
%clockleft)
if (%clockw2 <= 0) { set %clockw2 0.01 }
if (%clockleft <= 10) { set %clockcol #ed4245 }
if (%active == 1) { if (%clockleft > 0) { if (%practice == 0) { set %showclock 1 } } }
set %lobbyline $len(%seats) seated · Blinds
%sb/
%bb
if (%waiting == 1) { if (%clockleft > 0) { set %waitlabel Waiting for
$get(%name,
%turnfp)… · ⏱
%clockleft s
} }
if (%winlen > 0) { set %haswinner 1 }
if (%street == preflop
) { set %streetlabel PRE-FLOP
}
elseif (%street == flop
) { set %streetlabel FLOP
}
elseif (%street == turn
) { set %streetlabel TURN
}
elseif (%street == river
) { set %streetlabel RIVER
}
elseif (%street == lobby
) { set %streetlabel LOBBY
}
set %blindslabel Blinds
%sb/
%bb · Pot
%pot
; ---- per-seat display (precompute into maps) ----
if (%fp == %turnfp) { if (%active == 1) { set %bc #ffd166 | set %bw 4 } }
setat %seatborder %fp %bc
setat %seatborderw %fp %bw
if (%fp == %dealerfp) { set %badge D
| set %badgebg #f0c020 }
elseif (%fp == %sbfp) { set %badge SB
| set %badgebg #6c7bdc }
elseif (%fp == %bbfp) { set %badge BB
| set %badgebg #6c7bdc }
setat %seatbadge %fp %badge
setat %seatbadgebg %fp %badgebg
if ($get(%bet,
%fp) > 0) { set %sline BET
$get(%bet,
%fp) }
if ($get(%allin,
%fp) == 1) { set %sline ALL-IN
}
if ($get(%folded,
%fp) == 1) { set %sline FOLD
}
; a player with no chips who isn't all-in this hand is eliminated
if ($get(%stack,
%fp) <= 0) { if ($get(%allin,
%fp) != 1) { set %sline OUT
} }
setat %seatstatus %fp %sline
if ($get(%folded,
%fp) == 1) { set %av #3a3350 }
}
; my hole cards (split "c1 c2"); show backs until dealt
; ---- hand-rank badges: mine always, others only once their hole is revealed ----
if (%hashole == 1) { if (%bn > 0) { set %mycat $poker_handcat($get(%myhole,me
) $join(%board)) } }
if ($len(%mycat) > 0) { set %hasmycat 1 }
set %seatc1 $map() ; revealed hole cards per seat, populated only at showdown
; prefer the broadcast reveal (present on every client at showdown), fall back to the local
; hole map (the host has it live). This is why opponents' ranks/cards now show for everyone.
if ($len(%hh) > 0) { if (%bn > 0) { set %rk $poker_handcat(%hh $join(%board)) } }
setat %seathasrank %fp %hr
; the actual two cards to show under an opponent's seat at showdown
}
setat %seatreveal %fp %shown
; stable per-player emoji avatar from the first hex nibble of their fingerprint hash
}
; ---- ring seat order: hero first so the ring drops us at the bottom-centre (child 0),
; opponents fanning out around the oval like Discord's table. Not seated -> natural order. ----
; opponents sit along the top edge; the hero is shown in the hand panel at the bottom.
; Ring order: YOU first. ScriptView.Ring anchors child 0 at the bottom of the ellipse and walks the
; rest around it, so hero-first puts you at the near edge with everyone facing you across the felt.
if (%seated == 1) { push %ringseats %me }
; ---- orientation-aware table geometry. TUNE ON DEVICE. --------------------------------------
; One layout, two axes: the seats sit on the perimeter of a CAPSULE (stadium), and the ratio
; picks the axis. Portrait: vertical, you on the bottom cap, opponents up the straight sides.
; Landscape / TV: horizontal, opponents across the top edge facing you. The renderer grows
; the table with the seat count so seats can never overlap, and it sizes the felt to the
; exact seat path, so every pod straddles the rail: players AT the table, not floating above.
; landscape / TV: horizontal capsule (ratio < 1 picks the axis), opponents across the top
; edge facing you. The radius scales with the screen so a 16:9 TV gets a proper wide table.
if (%ringr > 260) { set %ringr 260 }
if (%ringr < 130) { set %ringr 130 }
}
; portrait: vertical capsule (ratio >= 1), you on the bottom cap, opponents flanking the
; straight sides with an odd opponent at the top apex.
}
; The felt is the ring child flagged `felt` below: the RENDERER sizes it to the exact seat
; path (and grows the table with the seat count), so nothing here needs to mirror renderer
; geometry. The huge corner radius clamps to a capsule in either orientation.
surface gradient linear:#1e2138:#0a0c18 bg #0a0c18 pad 7 {
column gap 8 pad 2 align center fill {
; ---- header: blurple crest · title · street pill ----
row gap 9 align center fill {
surface circle width 32 height 32 gradient linear:#5865f2:#4752c4 elevation 5 {
column align center { text "♠" bold color #ffffff textsize 16 }
}
column gap 0 weight 1 {
text "POKER NIGHT" bold color #ffffff textsize 15
text "%blindslabel" color #8a91a8 textsize 10
}
surface gradient linear:#5865f2:#4752c4 radius 20 pad 6 elevation 3 {
text "%streetlabel" bold color #ffffff textsize 10
}
if (%canend == 1) { button
"End" poker_stop bg
#2b3150 color
#ed4245 radius
12 height
34 }
}
; ---- table: opponents along the top edge, a compact square felt below. The hero sits in
; the hand panel at the bottom (further down), a phone-friendly top-vs-bottom table. ----
surface gradient linear:#151934:#0d1022 bg #12152b radius 24 pad 10 elevation 10 border #262b4d 1 fill {
column align center gap 9 fill {
; The table proper: an elliptical felt with a seat pod for every player arranged around
; its rim (you at the bottom). Replaces the old opponents-across-the-top strip, which read
; as a list of avatars rather than a table.
stack align center {
ring size %ringr ratio %ringratio stadium {
; Felt first, flagged `felt`: the renderer sizes it to the exact path the seats
; sit on, so every pod straddles the rail with half its avatar on the felt -
; players AT the table, not floating above it.
surface felt radius 999 gradient radial:#2c9c6a:#0f4a37 bg #12633f border #0a3327 5 elevation 6 {
column align center gap 5 fill {
spacer weight 1
surface gradient linear:#2fbf71:#12833f radius 14 pad 6 elevation 5 {
column align center gap 0 {
text "🏆" textsize 14
text "%winnertext" bold color #ffffff textsize 11
}
}
}
surface bg #0b2418 radius 14 pad 5 border #2f7d54 1 elevation 3 {
row gap 6 align center {
stack {
surface circle width 12 height 12 bg #c0392b border #ffffff 2 offsety 5 { spacer }
surface circle width 12 height 12 bg #2980b9 border #ffffff 2 offsety 3 { spacer }
surface circle width 12 height 12 bg #f0c020 border #ffffff 2 { spacer }
}
column align center gap 0 {
text "POT" bold color #7fd6a2 textsize 8
text %pot bold color #ffffff textsize 15
}
}
}
}
row gap 3 align center {
if (%idx < %bn) { card
$get(%board,
%idx) width
22 elevation
4 }
else { card
"" back width
22 elevation
2 }
}
}
spacer weight 1
}
}
column align center gap 2 {
stack {
surface circle width
34 height
34 elevation
4 border
$get(%seatborder,
%fp) $get(%seatborderw,
%fp) {
image
$get(%avatar,
%fp) circle width
34 height
34 crop
}
}
surface circle width
34 height
34 elevation
4 bg
$get(%seatav,
%fp) border
$get(%seatborder,
%fp) $get(%seatborderw,
%fp) {
column align center { text "$get(%seatemoji,%fp)" textsize 19 }
}
}
surface circle width
14 height
14 bg
$get(%seatbadgebg,
%fp) border
#101430 1 align bottom
{
text "$get(%seatbadge,%fp)" bold color #101430 textsize 7
}
}
surface bg
#1b2040 radius
8 pad
3 border
$get(%seatborder,
%fp) $get(%seatborderw,
%fp) elevation
2 {
column align center gap 0 {
text "$get(%name,%fp)" bold color #ffffff textsize 9
row gap 2 align center {
surface circle width 7 height 7 bg #f2c14e border #d99a2b 1 { spacer }
text
$get(%stack,
%fp) bold color
#ffd76b textsize
9
}
}
}
; after a move, the pod says what they did: what they put in, or that they are out,
; or the hand they are showing once the board makes one readable.
if ($get(%folded,
%fp) == 1) { surface bg
#241d33 radius
7 pad
2 { text
"FOLD" bold color
#7a7a8a textsize
8 } }
surface bg #2a2140 radius 9 pad 2 border #f0c020 1 {
row gap 3 align center {
text "$get(%lastact,%fp)" bold color #e6e9f2 textsize 8
if ($get(%bet,
%fp) > 0) { text
$get(%bet,
%fp) bold color
#ffd166 textsize
8 }
}
}
}
surface bg #2a2140 radius 9 pad 2 border #f0c020 1 {
row gap 2 align center {
surface circle width 7 height 7 bg #f0c020 border #ffffff 1 { spacer }
text
$get(%bet,
%fp) bold color
#ffd166 textsize
8
}
}
}
elseif ($get(%seathasrank,
%fp) == 1) { surface bg
#0a0a0a radius
6 pad
2 { text
"$get(%seatrank,%fp)" bold color
#f5f5f5 textsize
8 } }
; every box holds cards: yours face up, everyone else face down until showdown turns
; them over. A folded player shows none at all.
if (%fp == %me) { spacer
}
row gap
2 align center
{ card
$get(%seatc1,
%fp) width
16 elevation
3 | card
$get(%seatc2,
%fp) width
16 elevation
3 }
}
; != 1, not == 0: an unset map entry expands to empty, so a player who simply
; hasn't folded reads as "" and would fail an == 0 test.
if (%started == 1) { row gap
2 align center
{ card
"" back width
16 elevation
2 | card
"" back width
16 elevation
2 } }
}
}
}
}
}
}
}
; ---- your hand: big hole cards + rank (avatar/name/stack already show in the ring seat) ----
surface gradient linear:
#1a1e3c:
#141733 bg
#171232 radius
18 pad
9 elevation
6 border
$get(%seatborder,
%me) $get(%seatborderw,
%me) fill
{
row gap 12 align center {
column gap 4 weight 1 {
text "YOUR HAND" bold color #8a91a8 textsize 9
if (%hasmycat == 1) { surface bg
#2a2140 radius
8 pad
4 border
#f2c14e 1 { text
"%mycat" bold color
#ffe08a textsize
12 } }
elseif (%hashole == 1) { text
"Waiting for the flop" color
#8a91a8 textsize
11 }
else { text
"Cards come with the next deal" color
#8a91a8 textsize
11 }
row gap 4 align center {
surface circle width 10 height 10 bg #f2c14e border #d99a2b 1 { spacer }
text %mystack bold color #ffd76b textsize 12
}
}
row gap 7 {
if (%hashole == 1) { card
%h1 width
52 elevation
8 | card
%h2 width
52 elevation
8 }
else { card
"" back width
52 elevation
4 | card
"" back width
52 elevation
4 }
}
}
}
}
; ---- action bar (state-aware) ----
surface gradient linear:#1a1e3c:#141733 bg #171232 radius 20 pad 11 elevation 8 fill {
column gap 7 fill align center {
surface gradient linear:#f2c14e:#e0a52e radius 14 pad 6 elevation 4 { text "🏆 %overlabel" bold color #3a2e08 textsize 13 }
if (%cannewgame == 1) { button
"New Game" poker_newgame bg
#5865f2 color
#ffffff radius
14 bold fill height
52 }
else { text
"Waiting for the host to start a new game" color
#8a91a8 textsize
11 }
}
}
column gap 9 fill {
row gap 8 align center fill {
text "YOUR TURN" bold color #ffd76b textsize 11
text "%tocalllabel · Pot %pot" color #b9c0d4 textsize 11 weight 1
if (%showclock == 1) { text
"%clockleft s" bold color
%clockcol textsize
11 }
}
row gap 0 fill {
surface bg %clockcol radius 3 height 4 weight %clockw1 { spacer }
surface bg #2b3150 radius 3 height 4 weight %clockw2 { spacer }
}
}
row gap 8 fill {
if (%canfold == 1) { button
"Fold" poker_fold bg
#3a3f52 color
#e6e9f2 radius
14 bold weight
1 height
52 }
button "%calllabel" poker_call bg #3ba55d color #ffffff radius 14 bold weight 1 height 52
}
row gap 6 align center fill {
button "−" poker_dec bg #2b3150 color #e6e9f2 radius 14 bold width 52 height 52
button "%raiselabel" poker_raise bg #f2c14e color #3a2e08 radius 14 bold weight 1 height 52
button "+" poker_inc bg #2b3150 color #e6e9f2 radius 14 bold width 52 height 52
}
row gap 5 fill {
button "Min" poker_min bg #2b3150 color #cdd6e6 radius 12 weight 1 height 40
button "½ Pot" poker_h bg #2b3150 color #cdd6e6 radius 12 weight 1 height 40
button "Pot" poker_pot bg #2b3150 color #cdd6e6 radius 12 weight 1 height 40
button "All-in" poker_allin bg #5a2230 color #ffb3b8 radius 12 bold weight 1 height 40
}
}
}
}
column gap 7 fill align center {
text "%hostlabel" bold color #b9c0d4 textsize 12
if (%hosted == 1) { text
"%lobbyline" color
#8a91a8 textsize
10 }
button "%startlabel" poker_start bg #5865f2 color #ffffff radius 14 bold fill height 52
}
}
column gap 6 fill {
row gap 6 align center { text "%waitlabel" color #b9c0d4 textsize 12 }
row gap 0 fill {
surface bg %clockcol radius 3 height 3 weight %clockw1 { spacer }
surface bg #2b3150 radius 3 height 3 weight %clockw2 { spacer }
}
}
}
}
column gap 3 fill align center {
text "%seatwait" color #b9c0d4 textsize 12
text "%lobbyline" color #8a91a8 textsize 10
}
}
column gap 7 fill align center {
text "Tap to take a seat" color #b9c0d4 textsize 12
button "Join Table" poker_join bg #5865f2 color #ffffff radius 14 bold fill height 52
button "Practice vs Bots" poker_practice bg #2b3150 color #e6e9f2 radius 14 fill height 48
}
}
}
}
}
}
}