TabletopDeck
Server only. A deck of pieces players hold in their hands at a Tabletop, made with table.createDeck: playing cards by default, or your own pieces (tiles, tarot, a game's cards). It lies face down as a stack on the table; dealt pieces fly into the seated players' left hands, held as a fan whose faces only the holder's game gets, and played pieces are thrown with the right hand onto piles. The holder works their hand with keys (see Docs: Tabletop games), and every step of theirs is an event you can refuse, so the rules of your game are yours.
tabletopDeck.id
idThe deck's id.
tabletopDeck.table
tableThe table it lies on.
tabletopDeck.pieces
piecesEvery piece of the deck, wherever it is: in the stack, a hand, on a pile or in the air.
tabletopDeck.remaining
remainingHow many pieces are left in the stack.
tabletopDeck.piles
pilesThe names of its piles on the table: 'table' (where played pieces land, unless createDeck's playPile names another) and those addPile made.
tabletopDeck.exists
existsFalse once the deck or its table is gone.
tabletopDeck.shuffle()
shuffle()Shuffles the stack.
tabletopDeck.deal()
deal(players, count = 1)Deals `count` pieces (1 by default) from the top of the stack to a player or to each of a list, one round after another as a dealer does: each flies from the stack into the player's hand, a moment after the one before. The pieces are in the hands when they land; it answers them at once. Fewer when the stack runs out. Drawing one piece is deal(player).
tabletopDeck.dealTo()
dealTo(pile, count = 1, options = {})Deals `count` pieces from the stack onto a pile: `faceUp` (the pile's own by default) shows their faces. A poker flop, the first card of Prší face up.
tabletopDeck.hand()
hand(player)The pieces a player holds, in the fan's order from left to right.
tabletopDeck.selected()
selected(player)The pieces of a player's hand they have selected (raised out of the fan) to play together.
tabletopDeck.select()
select(piece, selected = true)Selects a piece of a hand, or lets it back into the fan with false; throws for a piece in nobody's hand.
tabletopDeck.play()
play(player, pieces, pile, options = {})The player throws pieces of their hand onto a pile (the play pile by default): their right hand takes each from the fan, swings over the table and lets go, and it flies on and lands, face up unless the pile or `faceUp` says otherwise. The promise settles true when they all lie there. The holder's own play key does this after deckPlayRequest; call it yourself for a play your script decides.
tabletopDeck.addPile()
addPile(name, options = {})Adds a pile, or changes one: `position` { x, y } metres from the table's middle on its own axes, `faceUp` (true by default), `layout` 'stack' (each piece on the one before, a little turned) or 'row' (side by side, `spacing` metres apart) and `rotation` degrees. At most 24 piles.
tabletopDeck.pile()
pile(name)The pieces on a pile, bottom first: its last is the top one.
tabletopDeck.move()
move(piece, pile, options = {})Moves any piece onto a pile: from the stack, another pile or a hand, without a throw. It flies there; `faceUp` (the pile's own by default). The promise settles true when it lies there.
tabletopDeck.flip()
flip(piece, faceUp)Turns a piece on a pile over, or face up or down as `faceUp` says.
tabletopDeck.reveal()
reveal(player)Shows a player's hand to everyone (a showdown): their fan's faces reach every game until conceal.
tabletopDeck.conceal()
conceal(player)Shows a revealed hand's faces to its holder only again.
tabletopDeck.cover()
cover(player)Lays a player's hand face down on the table before them, their left hand resting on it, as a player does who waits; false when they hold nothing or already covered it. The holder's cover key does this after deckCover.
tabletopDeck.uncover()
uncover(player)Takes a covered hand up again; false when it was not covered.
tabletopDeck.covered()
covered(player)Whether a player's hand lies covered on the table.
tabletopDeck.collect()
collect()Every piece back into the stack, face down: the hands and the piles fly back. The promise settles when they are there (false when the deck went meanwhile). Shuffle and deal again for the next round.
tabletopDeck.restock()
restock(pile, options = {})Turns a pile into the stack again when the stack runs out, as Prší does: its pieces fly back face down, but its top `keep` (1 by default), and the stack is shuffled (unless `shuffle` is false). The promise settles with how many went back.
tabletopDeck.setActions()
setActions(actions, player)Names the holder's draw, pass and look keys, the game's own key hints while they sit at the table: `draw` (E) asks for a piece from the stack (deckDrawRequest), `pass` (Space) passes, checks or stands (deckPass), `look` (holding E) steps through the close looks at the hand and the table, as C does. Each is a text of up to 48 characters, or false for no such key. With a player, only theirs (whose turn it is, say), until the deck's are set again. At first there are 'Pass' and 'Look closer' keys and no draw key.
tabletopDeck.actions()
actions(player)The labels of the draw, pass and look keys a player has (the deck's own without a player): { draw, pass, look }, each a text or false.
tabletopDeck.save()
save()The deck as a plain object to keep (with SharedState or a file): the stack's order, the hands with their order and the piles; each piece's data too.
tabletopDeck.load()
load(saved)Lays a saved deck out again: the stack, the piles, and the hands of the players still seated (the others' pieces go to the stack's bottom).
tabletopDeck.destroy()
destroy()Removes the deck: its pieces leave the hands and the table, and the holders' hands go down.