Reference
Cribbage
import { … } from "@johnmorrisdotca/toranpu/cribbage";
3.7 kB minified and gzipped, with everything it imports (measured with esbuild)
Cribbage: its rules, its computer player and its saved-game format.
Exports
| Name | Kind | What it is |
|---|---|---|
cardValue | function | A card's worth in the count: ace one, court cards ten. |
chooseCrib | function | The two cards to lay away: the four kept worth most on average with every starter, the crib counted for or against. |
choosePeg | function | The card to peg: most points now, then a count kept off five and twenty-one, a low lead that is not a five. |
CRIBBAGE_RULES | constant | Cribbage as one CardGameRules: everything a table asks of the game. |
CRIBBAGE_SEATS | constant | How many play Cribbage here: two. |
cribbageComputer | function | The move a computer in the seat to play makes: always one the rules allow. |
CribbageCount | type | What a hand's show is worth, by kind. |
CribbageGame | type | A GAME OF CRIBBAGE: its table and moves (what is kept, KeptCardGame), and everything the moves make, read again from them whenever the game is. |
CribbageHandScore | type | One hand as it was shown: the dealer, the starter, both four-card hands and the crib, and what each counted. |
CribbageMove | type | Two cards laid away to the crib, or one card played in the pegging. |
cribbageMoves | function | Every move the seat to play may make now; none once the game is over. |
CribbagePeg | type | What one card played in the pegging scored, and why: "fifteen", "a pair", "a run of three", "go", "last card", "thirty-one". |
CribbagePhase | type | Both players laying two cards to the crib, the pegging, or the game over. |
CribbagePlay | type | One card laid, and whose it was. |
cribbagePlayable | function | The cards a seat may play on the count now: any that keeps it to thirty-one. |
cribbageView | function | The part of the game the seat to play can see, which is all its computer is given. |
CribbageView | type | A COMPUTER AT THE CRIBBAGE TABLE. |
cribbageWinners | function | The first to the total. |
cribPairs | function | Every way to lay two of a hand away. |
dealerOf | function | The seat that deals this hand: the first seat, then the other, turn about. |
decodeCribbage | function | Text read back into the game of Cribbage it records, by playing every move again through the rules; null for anything they cannot play out. |
encodeCribbage | function | A game of Cribbage as text: its table, its seed and its moves, never a hand. |
otherOf | function | The seat that is not this one. |
pegPoints | function | What laying the last card of cards scores, the count now count: fifteen, thirty-one, pairs and runs. |
playCribbage | function | The game after that move, with the move added to its record, or null for a move the rules refuse. |
showCount | function | What four cards and the starter are worth in the show. |
sortCribbage | function | A hand sorted as a player holds it: ace low to king, by rank then suit. |
startCribbage | function | A new game of Cribbage for these players (one name a seat) at this size, dealt from the seed dealt, or null for a table Cribbage is not offered for. |
throwWorth | function | What two cards thrown to a crib are worth to it, roughly: a pair, a fifteen, fives, and cards close enough to run. |