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

War

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

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

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

Exports

NameKindWhat it is
decodeWarfunctionText read back into the game of War it records, by playing every move again through the rules; null for anything they cannot play out.
encodeWarfunctionA game of War as text: its table, its seed and its moves, never a pile.
isWarMovefunctionWhether something is the one move War has.
playWarfunctionThe game after the cards are turned over: the whole turn, through however many wars it takes, or null for a move the rules refuse.
startWarfunctionA new game of War for these two players at this size (how many turns it may last), dealt from the seed, or null for a table War is not offered for.
WAR_FACE_DOWNconstantThe cards a player lays in a war before the one turned up.
WAR_RULESconstantWar as one CardGameRules: everything a table asks of the game.
warComputerfunctionThe move a computer makes: the only one War has.
WarEndtypeWhy a game of War ended: one player has every card ("cleared"), a player could not finish a war and the other could, or both could not and one ran out first ("short"), both ran out together ("drawn"), or the turns ran out ("limit").
WarGametypeA GAME OF WAR: its table and moves (what is kept), and what they make.
WarLaidtypeOne card laid in a turn: who laid it, and whether it lay face down (the three of a war) or was turned up.
WarMovetypeThe one thing a player does at War: turn the top cards over.
warMovesfunctionEvery move the table may make now: turning the cards over, until the game is over.
warRankfunctionHow a rank counts at War: the ace highest, then king down to two.
WarTurntypeWhat the table saw of the last turn: every card laid, in the order laid, how many wars the turn went through (0 for a plain turn of the cards), and who took the cards (null when the turn ended the game on a war that was not finished).
warWinnersfunctionThe seats that won a game that is over: the player with more cards, both when the piles are level or the game was a draw; nobody while it goes on.

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