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

WarGametype

A GAME OF WAR: its table and moves (what is kept), and what they make. size is how many turns it may last, and hands are each player's cards, face down, the top card first. Nothing here is hidden: no player chooses anything.

Import it

import type { WarGame } from "@johnmorrisdotca/toranpu/war";

Definition

type WarGame = KeptCardGame<WarMove> & {
    phase: "playing" | "over";
    hands: CardId[][];
    toPlay: number | null;
    last: WarTurn | null;
    ended: WarEnd | null;
};

Members

NameTypeDescription
sizenumber
playersreadonly string[]
computersreadonly boolean[]
seednumber
movesreadonly WarMove[]
phase"playing" | "over"
handsstring[][]

Each player's pile, top card first.

toPlaynumber | null

The seat the table waits on: the first person's, or the first seat when computers hold both. Null once over.

lastWarTurn | null

The last turn, for the table to show; null before the first.

endedWarEnd | null

Why the game ended; null while it goes on.

Examples

import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { WarGame } from "@johnmorrisdotca/toranpu/war";

const names = Array.from({ length: CARD_GAME_TABLES.war.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
const game = newGame("war", { players: names, seed: 42 })!;
const value: WarGame = game;
console.log(value.phase);
playing

What it prints (run when this page was built)

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