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
| Name | Type | Description |
|---|---|---|
size | number | |
players | readonly string[] | |
computers | readonly boolean[] | |
seed | number | |
moves | readonly WarMove[] | |
phase | "playing" | "over" | |
hands | string[][] | Each player's pile, top card first. |
toPlay | number | null | The seat the table waits on: the first person's, or the first seat when computers hold both. Null once over. |
last | WarTurn | null | The last turn, for the table to show; null before the first. |
ended | WarEnd | 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);playingWhat it prints (run when this page was built)