Toranpu documentation
Toranpu トランプ — Playing cards, card games and solitaire
Use a deck, play eleven games with computers, solve a solitaire, or display cards in your own design.
Install
npm install @johnmorrisdotca/toranpu
Start here
Entry points
| Import it | What it is | Size |
|---|---|---|
@johnmorrisdotca/Deck tools · 36 exports | The deck on its own: fifty-two cards as objects ({ suit, rank }), a seeded shuffle, dealing, one-character and two-character codes, and the names a card is written and spoken by. | 1.5 kB |
@johnmorrisdotca/React components · 2 exports | 27.3 kB | |
@johnmorrisdotca/Sound controls · 10 exports | The sounds of a card table, from real recorded cards: a card dealt, turned over or played, the deck shuffled, a pile gathered in, a hand fanned. | 42.9 kB |
@johnmorrisdotca/Recorded sounds · 2 exports | 41.0 kB | |
@johnmorrisdotca/Card backs · 15 exports | The backs of the cards, drawn as SVG: one home for every card game in the family. | 3.5 kB |
@johnmorrisdotca/Card designs · 22 exports | The faces of the cards, drawn as SVG in the same 100 by 140 box as the backs: plain (unless said), four colour, and the English pattern with its drawn kings, queens and jacks, which is its own entry point because of its size. | 187.4 kB |
@johnmorrisdotca/English faces · 1 exports | The English pattern: the traditional deck with its kings, queens and jacks, as vectors by Dmitry Fomin, who dedicated them to the public domain (CC0) on Wikimedia Commons; the jokers are his too, from his Atlas deck, with the corner word drawn afresh. | 164.2 kB |
@johnmorrisdotca/Realistic faces · 1 exports | The realistic design: Byron Knoll's number cards and aces, which he released into the public domain (Wikimedia Commons), with the kings, queens, jacks, ace of spades and jokers of Dmitry Fomin's CC0 English pattern. | 169.7 kB |
@johnmorrisdotca/Cards, hands and piles · 28 exports | Toranpu's custom elements, for any page and any framework that renders HTML, and the arithmetic behind them: | 242.8 kB |
@johnmorrisdotca/Register card tags · 28 exports | The custom elements, registered by being imported: | 242.8 kB |
@johnmorrisdotca/Playable table · 4 exports | <toranpu-table>: any of the ten games, ready to play on a page — the seats, the felt in any of the family's cloths, the trick and the piles (the stock and the discard as <toranpu-pile>, as untidy as asked), the hand of whoever is to play and the moves they may make, with computers in every other seat. | 263.4 kB |
@johnmorrisdotca/Register table tag · 4 exports | <toranpu-table>, registered by being imported: | 263.4 kB |
@johnmorrisdotca/Hearts · 24 exports | Hearts: its rules, its computer player and its saved-game format. | 3.6 kB |
@johnmorrisdotca/Spades · 30 exports | Spades: its rules, its computer player and its saved-game format. | 3.8 kB |
@johnmorrisdotca/Euchre · 29 exports | Euchre: its rules, its computer player and its saved-game format. | 3.8 kB |
@johnmorrisdotca/Cribbage · 29 exports | Cribbage: its rules, its computer player and its saved-game format. | 3.7 kB |
@johnmorrisdotca/Oh Hell · 26 exports | Oh Hell: its rules, its computer player and its saved-game format. | 3.2 kB |
@johnmorrisdotca/Crazy Eights · 21 exports | Crazy Eights: its rules, its computer player and its saved-game format. | 3.1 kB |
@johnmorrisdotca/Go Fish · 19 exports | Go Fish: its rules, its computer player and its saved-game format. | 2.9 kB |
@johnmorrisdotca/Big Two · 31 exports | Big Two: its rules, its computer player and its saved-game format. | 3.9 kB |
@johnmorrisdotca/President · 29 exports | President: its rules, its computer player and its saved-game format. | 3.5 kB |
@johnmorrisdotca/Gin Rummy · 31 exports | Gin Rummy: its rules, its computer player and its saved-game format. | 3.8 kB |
@johnmorrisdotca/War · 16 exports | War: its rules, its computer player and its saved-game format. | 2.3 kB |
@johnmorrisdotca/Klondike · 47 exports | Klondike, the Solitaire: its table, its rules, its moves written as text, a solver, and what a tap on the table means. | 3.9 kB |
@johnmorrisdotca/FreeCell · 45 exports | FreeCell: its table, its rules, its moves written as text, a solver, and what a tap on the table means. | 3.7 kB |
@johnmorrisdotca/Spider · 38 exports | Spider: its table at one, two or four suits, its rules, its moves written as text, a solver, and what a tap on the table means. | 3.4 kB |
@johnmorrisdotca/Games and state · 101 exports | Toranpu トランプ: a deck of playing cards and eleven card games to play with it, each with a computer player. | 36.1 kB |
Guides
How-to
- Run computer turnsChoose which seats are computers, step them through a game, and show their moves in order.
- Save, restore and exportSave a game as its setup and moves, read it back by replaying them, and export JSON, a code, text or CSV.
- Display and brand cardsDraw cards and backs as SVG, register your own designs, and show them with elements.
- Deal, play and solve solitairesDeal, play and solve Klondike, FreeCell and Spider with their own engines.
- Embed cards or use ReactRegister the card tags, use the builder, and drive a table from React hooks.
Explanation
- Engine, views and replaySee how the rules engines share one shape, how state and deals are reproduced, and how the entry points divide.
- Card representations and layoutsKnow the three ways a card is written, and keep layout and spoken names apart from game state.