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

Spades

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

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

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

Exports

NameKindWhat it is
chooseBidfunctionNil for a hand of nothing (and never beside a partner's nil); otherwise what the hand is worth, at least one.
contractOffunctionA partnership's contract this deal: its bids added, a nil counting none; null while either has still to bid.
dealerOffunctionThe seat that deals this deal: the first seat, then round to the left.
decodeSpadesfunctionText read back into the game of Spades it records, by playing every move again through the rules; null for anything they cannot play out.
encodeSpadesfunctionA game of Spades as text: its table, its seed and its moves, never a hand.
handWorthfunctionThe tricks a hand is worth, counted as a card player counts them before bidding.
NILconstantThe bid that means no tricks at all.
partnerOffunctionThe seat across the table.
partnershipScorefunctionWhat one partnership made of a deal: its contract (the two bids, a nil counting none) made or not, each nil made or not, and the overtricks — the tricks over the contract, and any trick a nil bidder took — as bags.
playSpadesfunctionThe game after that move, with the move added to its record, or null for a move the rules refuse.
sortSpadesfunctionA hand sorted as a player holds it: diamonds, clubs, hearts, spades, low to high within each.
SPADES_BIDSconstantThe bids open to a player: nil, or one to thirteen tricks.
SPADES_RULESconstantSpades as one CardGameRules: everything a table asks of the game.
SPADES_SEATSconstantHow many play Spades: four, in two partnerships.
SPADES_TRICKSconstantThe tricks in a deal of Spades: thirteen.
spadesComputerfunctionThe move a computer in the seat to play makes: always one the rules allow.
SpadesDealScoretypeWhat one finished deal did to a partnership's score, as the scores table explains it.
SpadesGametypeA GAME OF SPADES: its table and moves (what is kept, KeptCardGame), and everything the moves make, read again from them whenever the game is.
spadesHeightfunctionA card's height in a trick: ace high.
SpadesMovetypeA bid of tricks, 0 (nil) to 13, or one card played to the trick.
spadesMovesfunctionEvery move the seat to play may make now; none once the game is over.
SpadesPhasetypeBidding how many tricks each seat will take, playing the deal out trick by trick, or the game over.
SpadesPlaytypeOne card laid on a trick, and whose it was.
spadesPlayablefunctionThe cards the seat to play may lay on the trick now.
spadesTrickWinnerfunctionWho takes a finished trick (or is winning one still being played): the highest spade, or else the highest card of the suit led.
spadesViewfunctionThe part of the game the seat to play can see, which is all its computer is given.
SpadesViewtypeWhat the seat to move can see: its own hand, every bid, the tricks taken and the cards played.
spadesWinnersfunctionThe partnership with the higher score wins, both its seats.
startSpadesfunctionA new game of Spades for these players (one name a seat) at this size, dealt from the seed dealt, or null for a table Spades is not offered for.
teamOffunctionA seat's partnership: 0 for seats 0 and 2, 1 for seats 1 and 3.

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