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
| Name | Kind | What it is |
|---|---|---|
choosePass | function | The 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. |
decodeHearts | function | Text read back into the game of Hearts it records, by playing every move again through the rules; null for anything they cannot play out. |
encodeHearts | function | A game of Hearts as text: its table, its seed and its moves, never a hand. |
HEARTS_ALL_POINTS | constant | Every point in a deal: thirteen hearts and the queen. |
HEARTS_RULES | constant | Hearts as one CardGameRules: everything a table asks of the game. |
heartsComputer | function | The move a computer in the seat to play makes: always one the rules allow. |
HeartsGame | type | A GAME OF HEARTS: its table and moves (what is kept, KeptCardGame), and everything the moves make, read again from them whenever the game is. |
heartsHeight | function | A card's height in a trick: ace high. |
HeartsMove | type | Three cards passed (all three at once, as a player hands them over), or one card played to the trick. |
heartsMoves | function | Every move the seat to play may make now; none once the game is over. |
HeartsPhase | type | Passing three cards before the deal is played, playing it out trick by trick, or the game over. |
HeartsPlay | type | One card laid on a trick, and whose it was. |
heartsPlayable | function | The cards the seat to play may lay on the trick now. |
heartsPoints | function | A card's points: a heart one, the queen of spades thirteen. |
heartsView | function | The part of the game the seat to play can see, which is all its computer is given. |
HeartsView | type | What the seat to move can see: its own hand and the table. |
heartsWinners | function | The lowest score wins; level on the lowest shares it. |
passOffset | function | How far round the table the cards go this deal: 1 to the left, seats − 1 to the right, 2 across, 0 held. |
playHearts | function | The game after that move, with the move added to its record, or null for a move the rules refuse. |
QUEEN_OF_SPADES | constant | The queen of spades, worth thirteen points to whoever takes her. |
sortHearts | function | A hand sorted as a player holds it: clubs, diamonds, spades, hearts, low to high within each. |
startHearts | function | A 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. |
trickWinner | function | Who takes a finished trick: the highest card of the suit led. |
TWO_OF_CLUBS | constant | The two of clubs, which leads the first trick of every deal. |