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
| Name | Kind | What it is |
|---|---|---|
decodeWar | function | Text read back into the game of War it records, by playing every move again through the rules; null for anything they cannot play out. |
encodeWar | function | A game of War as text: its table, its seed and its moves, never a pile. |
isWarMove | function | Whether something is the one move War has. |
playWar | function | The game after the cards are turned over: the whole turn, through however many wars it takes, or null for a move the rules refuse. |
startWar | function | A 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_DOWN | constant | The cards a player lays in a war before the one turned up. |
WAR_RULES | constant | War as one CardGameRules: everything a table asks of the game. |
warComputer | function | The move a computer makes: the only one War has. |
WarEnd | type | Why 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"). |
WarGame | type | A GAME OF WAR: its table and moves (what is kept), and what they make. |
WarLaid | type | One card laid in a turn: who laid it, and whether it lay face down (the three of a war) or was turned up. |
WarMove | type | The one thing a player does at War: turn the top cards over. |
warMoves | function | Every move the table may make now: turning the cards over, until the game is over. |
warRank | function | How a rank counts at War: the ace highest, then king down to two. |
WarTurn | type | What 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). |
warWinners | function | The 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. |