Reference
Stack Up
import { … } from "@johnmorrisdotca/toranpu/stack-up";
3.1 kB minified and gzipped, with everything it imports (measured with esbuild)
Stack Up: its rules, its computer player and its saved-game format.
Exports
| Name | Kind | What it is |
|---|---|---|
decodeStackUp | function | Text read back into the game of Stack Up it records, by playing every move again through the rules; null for anything they cannot play out. |
encodeStackUp | function | A game of Stack Up as text: its table, its seed and its moves, never a hand. |
isStackUpMove | function | Whether something is a move Stack Up has, by its shape. |
playStackUp | function | The game after a move, or null for a move the rules refuse. |
STACK_UP_DECK | constant | The whole deck of 162 cards, in a fixed order: 1 to 12 twelve times over, then the wilds. |
STACK_UP_HAND | constant | How many cards a hand is drawn up to. |
STACK_UP_PILES | constant | The four building piles in the middle, and the four discard piles each player has. |
STACK_UP_RULES | constant | Stack Up as one CardGameRules: everything a table asks of the game. |
STACK_UP_STOCKS | constant | The sizes of a stock pile a table is offered. |
STACK_UP_TOP | constant | The highest number on a card, and the length a building pile is finished at. |
STACK_UP_WILD | constant | The wild card's name. |
stackUpComputer | function | The move a computer makes: the best play it has, or else the card it would miss least, put where it does least harm. |
StackUpEnd | type | Why a game is over: someone played their last stock card, or nothing could be played for a whole round with no cards left to draw, and the fewest stock cards left wins. |
stackUpFits | function | Whether a card may go on a building pile: a wild always, a number when it is the one the pile wants. |
StackUpGame | type | A game of Stack Up: every seat's stock, hand and four discard piles, the four building piles, the cards still to draw and the finished piles waiting to be shuffled back in. |
StackUpMove | type | One move at Stack Up: a card laid on a building pile (from the hand, the top of the stock, or the top of one of your own discard piles), a card put on a discard pile, which ends the turn, or a pass when there is nothing in hand to discard. |
stackUpMoves | function | Every move the seat to play may make: each card that fits a building pile, from the hand, the stock or a discard pile; each card of the hand on each discard pile; and a pass when the hand is empty. |
stackUpValue | function | What a card counts for: its number 1 to 12, or 0 for a wild, which is whatever a pile wants. |
stackUpWants | function | What number a building pile wants next: one more than the cards on it. |
stackUpWinners | function | The seats that won a game that is over: the one who emptied their stock, or at a stuck table those with the fewest cards left; empty while it is being played. |
startStackUp | function | A new game of Stack Up for two to six players with a stock pile of this size, dealt from the seed, or null for a table it is not offered for. |