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

Crazy Eights

import { … } from "@johnmorrisdotca/toranpu/crazy-eights";

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

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

Exports

NameKindWhat it is
CRAZY_EIGHTS_RULESconstantCrazy Eights as one CardGameRules: everything a table asks of the game.
crazyEightsComputerfunctionThe move a computer in the seat to play makes: always one the rules allow.
CrazyEightsGametypeA GAME OF CRAZY EIGHTS: its table and moves (what is kept), and the hand they have reached.
CrazyEightsMovetypeA card played (an eight names the suit to follow), a card drawn from the stock, or a turn passed.
crazyEightsMovesfunctionEvery move the seat to play may make now; none once the game is over.
CrazyEightsResulttypeHow a hand ended: who won it, and the points each winner took.
crazyEightsViewfunctionThe part of the game the seat to play can see, which is all its computer is given.
CrazyEightsViewtypeWhat one seat can see of a game of Crazy Eights: its own hand, the table, and what has been said and shown.
crazyEightsWinnersfunctionThe highest score wins, once somebody reaches the game's size; level on it shares the win.
crazyHandSizefunctionSeven cards each for two players, five for more.
crazyMatchesfunctionWhether this card may go on the pile now: an eight always; otherwise the suit to follow or the top card's rank.
crazyPlayablefunctionThe cards the player to move may play now: after drawing, only the card drawn.
crazyPointsfunctionWhat a card left in hand is worth to the winner of the hand.
crazyTopfunctionThe card on top of the discard pile.
decodeCrazyEightsfunctionText read back into the game of Crazy Eights it records, by playing every move again through the rules; null for anything they cannot play out.
EIGHTconstantThe rank that is wild in Crazy Eights.
encodeCrazyEightsfunctionA game of Crazy Eights as text: its table, its seed and its moves, never a hand.
longestSuitfunctionThe suit this hand holds most of, eights aside; clubs first among equals so the choice is always the same.
playCrazyEightsfunctionThe game after that move, with the move added to its record, or null for a move the rules refuse.
sortCrazyfunctionA hand as a player holds it: eights last, the rest by suit and rank.
startCrazyEightsfunctionA new game of Crazy Eights for these players (one name a seat) at this size, dealt from the seed dealt, or null for a table Crazy Eights is not offered for.

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