Skip to the content

Toranpuトランプ

Use a deck, play twelve games with computers, solve a solitaire, or display cards in your own design.

Toranpu is Japanese for playing cards. About the name

Contents

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

NameKindWhat it is
decodeStackUpfunctionText 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.
encodeStackUpfunctionA game of Stack Up as text: its table, its seed and its moves, never a hand.
isStackUpMovefunctionWhether something is a move Stack Up has, by its shape.
playStackUpfunctionThe game after a move, or null for a move the rules refuse.
STACK_UP_DECKconstantThe whole deck of 162 cards, in a fixed order: 1 to 12 twelve times over, then the wilds.
STACK_UP_HANDconstantHow many cards a hand is drawn up to.
STACK_UP_PILESconstantThe four building piles in the middle, and the four discard piles each player has.
STACK_UP_RULESconstantStack Up as one CardGameRules: everything a table asks of the game.
STACK_UP_STOCKSconstantThe sizes of a stock pile a table is offered.
STACK_UP_TOPconstantThe highest number on a card, and the length a building pile is finished at.
STACK_UP_WILDconstantThe wild card's name.
stackUpComputerfunctionThe move a computer makes: the best play it has, or else the card it would miss least, put where it does least harm.
StackUpEndtypeWhy 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.
stackUpFitsfunctionWhether a card may go on a building pile: a wild always, a number when it is the one the pile wants.
StackUpGametypeA 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.
StackUpMovetypeOne 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.
stackUpMovesfunctionEvery 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.
stackUpValuefunctionWhat a card counts for: its number 1 to 12, or 0 for a wild, which is whatever a pile wants.
stackUpWantsfunctionWhat number a building pile wants next: one more than the cards on it.
stackUpWinnersfunctionThe 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.
startStackUpfunctionA 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.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/toranpu 2.17.0.