本文へ移動

Toranpuトランプ

デッキを使い、11種類のゲームでコンピューターと対戦し、ソリティアを解いたり、独自の絵柄でカードを表示したりできます。

「トランプ」は、日本語で playing cards を指す言葉です。 名前について(英語)

目次

リファレンス

ゲームと状態

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

最小化と gzip 圧縮をしたサイズは 36.1 kB(読み込むものをすべて含み、esbuild で計測)

リファレンスの説明と例は英語です。見出しと目次は日本語です。

Toranpu トランプ: a deck of playing cards and eleven card games to play with it, each with a computer player.

  • Every game by name: newGame, rulesFor, playComputers, and every game's rules in CARD_GAME_RULES.
  • Each game's own functions and types, as a namespace here (hearts, spades…) or from its own entry point (@johnmorrisdotca/toranpu/hearts).
  • The cards the games deal, as two-letter ids ("QS", "TD"), and the helpers every game shares: dealing, seats, choices, the saved-game format.
  • The deck as card objects, for a game of your own: @johnmorrisdotca/toranpu/deck.
  • Any game written out and read back (toJSON, fromJSON, toCode, toText, toCSV), and the games, cards and moves in words, in English and Japanese (gameName, cardText, moveText, STRINGS).
  • The command line as a function: runCli.

エクスポート

名前種類概要
allDifferent関数Whether a list names no card twice.
BIG_TWO_DEALS定数How many deals a game of Big Two may last.
bigTwo名前空間
CARD_GAME_KINDS定数The eleven kinds by name, for code that would rather not type a string twice.
CARD_GAME_LIST定数Every card game.
CARD_GAME_RULES定数EVERY CARD GAME'S RULES, by kind: what a table plays and what the simulation plays out.
CARD_GAME_TABLES定数Every game's table: the fewest, the most and the usual number of players, the lengths of game offered and the usual one.
cardGameCodec関数The keeping for one game: game names it, so one game's text is never read as another's; start and play are its rules; isMove checks a move's shape before the rules are asked about it.
CardGameCodec型A game's keeping: encode writes it as text, decode reads it back or gives null.
CardGameKind型THE CARD GAMES, and the tables each offers.
CardGamePlays型Each card game's game and move, so its rules can be named with their own types.
CardGameRules型WHAT EVERY CARD GAME'S RULES ANSWER, whatever the game.
CardGameTable型What a game's table offers: how many may sit at it, and how long a game may last.
CardId型A card by its short name: rank letter then suit letter, "QS", "TD", "AH" (cards.ts).
cardOf関数The card of this rank and suit.
cardOfId関数The deck's card for an id, for the deck's components to draw.
CardRank型The deck's rank, ace low: 1 is the ace, 11 the jack, 12 the queen, 13 the king.
CardSeats型Who sits in each seat: the name the set-up gave, and whether a computer plays it.
cardShort関数A card as a corner shows it: "Q♠", "10♦".
cardsShort関数Cards as corners show them, with a space between: "Q♠ 10♦ A♥".
CardSuit型Clubs, diamonds, hearts, spades.
cardText関数A card's name in full: "queen of spades", or "スペードのクイーン" in Japanese.
cardWords関数"queen of spades", as a sentence and a screen reader say it.
choices関数Every way of choosing count of these cards, in the order they are given.
cliLanguage関数The language the command line speaks: --lang, or the environment's, or the system's; Japanese for ja…, English for anything else.
CliResult型What the command line came to.
CliSurroundings型What the command line is run in.
computerSeats関数The seats a computer plays, one a seat, from what the set-up said: a seat it said nothing about is a person's.
CRAZY_EIGHTS_SIZES定数The scores a game of Crazy Eights may be played to.
crazyEights名前空間
cribbage名前空間
CRIBBAGE_SIZES定数The scores a game of Cribbage may be played to: once round the board, or twice.
CSV_COLUMNS定数The columns of the CSV, in order.
dealRound関数Deals the cards one at a time round the table, from the first seat, as a dealer does: each to a seat, or every card when each is absent (so some seats hold one more than others).
euchre名前空間
EUCHRE_SIZES定数The scores a game of Euchre may be played to.
fillIn関数Put values into a string's braces: fillIn("Bid {n}", { n: 3 }) is "Bid 3".
fromCode関数A game from its code or its JSON: the same as fromJSON, under the name that pairs with toCode.
fromJSON関数A game from text that toJSON or toCode wrote, whichever game it is.
FULL_DECK定数Every card, in the deck's own order.
gameName関数A game's name: "Hearts", or "ハーツ" in Japanese.
GameOf型A game of that kind, in progress.
gameSays関数A game in a line: what it is about, for a list of games.
GIN_SIZES定数The scores a game of Gin Rummy may be played to.
ginRummy名前空間
GO_FISH_SIZES定数Go Fish is one deal: its only size is 1.
goFish名前空間
hearts名前空間
HEARTS_SIZES定数How long each game lasts, in its own terms (see above).
isCard関数Whether this is one of the fifty-two names.
isCardList関数A list of card names, checked for shape only: whether they are cards the game holds is the rules' to say.
KeptCardGame型What every card game's state carries for its keeping.
Language型The languages Toranpu speaks.
languageOf関数The language a tag such as ja-JP or en_US.UTF-8 names: Japanese for anything that starts ja, English otherwise.
mixSeed関数Two numbers folded into one seed, so each deal of a game (and each reshuffle within one) has its own order.
MoveOf型A move in a game of that kind.
moveText関数A move in words, for any of the eleven games: moveText("hearts", { play: "QS" }) is "Play Q♠", and with { form: "did" } it is "plays Q♠".
MoveTextOptions型How a move is put into words.
namesList関数Names in a list: "Ann, Ben", or "Ann、Ben" in Japanese.
newGame関数A new game of that kind, or null when the game is not offered for that table (too many players, or a size it does not play to).
NewGameOptions型How to seat a new game.
nextSeat関数The next seat round the table, to the left: the order every game here plays in.
OH_HELL_DEALS定数How many deals a game of Oh Hell may last: up to seven cards, or up and back down.
ohHell名前空間
playComputers関数Every computer move due, played in turn until a person is to move or the game is over.
president名前空間
PRESIDENT_ROUNDS定数How many rounds a game of President may last.
Random型A number in [0, 1), like Math.random, from a stream a seed fixes.
randomSeed関数A seed for a game nobody asked for by number: a whole number from 1 to 2³¹ − 1.
RANK_LETTERS定数The rank letters, ace low: an index here plus one is the rank (A = 1, J = 11, Q = 12, K = 13).
rankName関数A rank as a sentence names one card of it: "queen", "seven"; in Japanese "クイーン", "7".
rankOf関数A card's rank, ace low: 1 to 13.
rankWords関数A rank named in the plural, as it is asked for: "sevens", "sixes", "queens".
ReadGame型A game read back: which game it is, and the game itself.
RecordedMove型One move of a record: which seat made it, and the move.
recordOf関数Every move of a game with the seat that made it, in order, found by playing the game through again from its seed.
reshuffled関数These cards shuffled again, the same way for the same seed and salt: a pile turned over to make a new stock.
rulesFor関数A game's rules by its kind, with its own game and move types.
runCli関数Run the command line.
SAVE_FORMAT定数The shape of the JSON this package writes.
savedGame関数A game as the object toJSON writes: its table, its seed and its moves.
SavedGame型A game as toJSON writes it.
seededRandom関数A stream of numbers in [0, 1) fixed by a seed.
shuffled関数A copy of the list in a random order (Fisher–Yates); the list given is left alone.
shuffledDeck関数The deck shuffled for one deal of one game: the same seed and deal always the same order, so a game kept as its seed and moves deals itself again exactly, and reloading can never re-deal a hand somebody has seen.
spades名前空間
SPADES_SIZES定数The scores a game of Spades may be played to.
STRINGS定数Every string, in both languages.
suitName関数A suit's name: "spades", or "スペード" in Japanese.
suitOf関数A card's suit, as its letter: S, H, D or C.
suitSymbol関数A suit's symbol: ♠ ♥ ♦ ♣.
suitWords関数A suit's name: "spades".
toCode関数A game as its code: the one line its own rules' encode writes.
toCSV関数A game's moves as CSV for a spreadsheet: a header, then a row a move, with its number from 1, the seat from 1 and its player, the kind of move (play, bid, pass…), the cards it names as two-letter ids with spaces between, the move itself as JSON, and the move in English.
toJSON関数A game as JSON, two spaces deep, with the format's number first.
ToranpuStrings型The names of the strings.
toText関数A game as a record a person can read: a heading, a numbered line a move with who made it, and how it stands.
VERSION定数The version of this package, as package.json has it.
war名前空間
WAR_ROUNDS定数How many turns of the cards a game of War may last before the player holding more cards wins.
without関数The hand without these cards, or null when it does not hold every one of them.

ソースを見るGitHub で編集@johnmorrisdotca/toranpu 2.15.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。