Skip to the content

Toranpuトランプ

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

Toranpu is Japanese for playing cards. About the name

Contents

Reference

Hearts

import { … } from "@johnmorrisdotca/toranpu/hearts";

3.6 kB minified and gzipped, with everything it imports (measured with esbuild)

Hearts: its rules, its computer player and its saved-game format.

Exports

NameKindWhat it is
choosePassfunctionThe three cards a computer passes from a hand of Hearts: the queen of spades and the high spades that catch her, high hearts, and cards from a short suit.
decodeHeartsfunctionText read back into the game of Hearts it records, by playing every move again through the rules; null for anything they cannot play out.
encodeHeartsfunctionA game of Hearts as text: its table, its seed and its moves, never a hand.
HEARTS_ALL_POINTSconstantEvery point in a deal: thirteen hearts and the queen.
HEARTS_RULESconstantHearts as one CardGameRules: everything a table asks of the game.
heartsComputerfunctionThe move a computer in the seat to play makes: always one the rules allow.
HeartsGametypeA GAME OF HEARTS: its table and moves (what is kept, KeptCardGame), and everything the moves make, read again from them whenever the game is.
heartsHeightfunctionA card's height in a trick: ace high.
HeartsMovetypeThree cards passed (all three at once, as a player hands them over), or one card played to the trick.
heartsMovesfunctionEvery move the seat to play may make now; none once the game is over.
HeartsPhasetypePassing three cards before the deal is played, playing it out trick by trick, or the game over.
HeartsPlaytypeOne card laid on a trick, and whose it was.
heartsPlayablefunctionThe cards the seat to play may lay on the trick now.
heartsPointsfunctionA card's points: a heart one, the queen of spades thirteen.
heartsViewfunctionThe part of the game the seat to play can see, which is all its computer is given.
HeartsViewtypeWhat the seat to move can see: its own hand and the table.
heartsWinnersfunctionThe lowest score wins; level on the lowest shares it.
passOffsetfunctionHow far round the table the cards go this deal: 1 to the left, seats − 1 to the right, 2 across, 0 held.
playHeartsfunctionThe game after that move, with the move added to its record, or null for a move the rules refuse.
QUEEN_OF_SPADESconstantThe queen of spades, worth thirteen points to whoever takes her.
sortHeartsfunctionA hand sorted as a player holds it: clubs, diamonds, spades, hearts, low to high within each.
startHeartsfunctionA new game of Hearts for these players (one name a seat) at this size, dealt from the seed dealt, or null for a table Hearts is not offered for.
trickWinnerfunctionWho takes a finished trick: the highest card of the suit led.
TWO_OF_CLUBSconstantThe two of clubs, which leads the first trick of every deal.

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