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

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

NameKindWhat it is
cardValuefunctionA card's worth in the count: ace one, court cards ten.
chooseCribfunctionThe two cards to lay away: the four kept worth most on average with every starter, the crib counted for or against.
choosePegfunctionThe card to peg: most points now, then a count kept off five and twenty-one, a low lead that is not a five.
CRIBBAGE_RULESconstantCribbage as one CardGameRules: everything a table asks of the game.
CRIBBAGE_SEATSconstantHow many play Cribbage here: two.
cribbageComputerfunctionThe move a computer in the seat to play makes: always one the rules allow.
CribbageCounttypeWhat a hand's show is worth, by kind.
CribbageGametypeA GAME OF CRIBBAGE: its table and moves (what is kept, KeptCardGame), and everything the moves make, read again from them whenever the game is.
CribbageHandScoretypeOne hand as it was shown: the dealer, the starter, both four-card hands and the crib, and what each counted.
CribbageMovetypeTwo cards laid away to the crib, or one card played in the pegging.
cribbageMovesfunctionEvery move the seat to play may make now; none once the game is over.
CribbagePegtypeWhat one card played in the pegging scored, and why: "fifteen", "a pair", "a run of three", "go", "last card", "thirty-one".
CribbagePhasetypeBoth players laying two cards to the crib, the pegging, or the game over.
CribbagePlaytypeOne card laid, and whose it was.
cribbagePlayablefunctionThe cards a seat may play on the count now: any that keeps it to thirty-one.
cribbageViewfunctionThe part of the game the seat to play can see, which is all its computer is given.
CribbageViewtypeA COMPUTER AT THE CRIBBAGE TABLE.
cribbageWinnersfunctionThe first to the total.
cribPairsfunctionEvery way to lay two of a hand away.
dealerOffunctionThe seat that deals this hand: the first seat, then the other, turn about.
decodeCribbagefunctionText read back into the game of Cribbage it records, by playing every move again through the rules; null for anything they cannot play out.
encodeCribbagefunctionA game of Cribbage as text: its table, its seed and its moves, never a hand.
otherOffunctionThe seat that is not this one.
pegPointsfunctionWhat laying the last card of cards scores, the count now count: fifteen, thirty-one, pairs and runs.
playCribbagefunctionThe game after that move, with the move added to its record, or null for a move the rules refuse.
showCountfunctionWhat four cards and the starter are worth in the show.
sortCribbagefunctionA hand sorted as a player holds it: ace low to king, by rank then suit.
startCribbagefunctionA 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.
throwWorthfunctionWhat two cards thrown to a crib are worth to it, roughly: a pair, a fifteen, fives, and cards close enough to run.

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