import type { CardId } from "../card-games.types.ts"; import type { WarGame, WarMove } from "./war.types.ts"; /** * WAR: the rules, and nothing else. * * Two players. The deck is shuffled and split, twenty-six cards each, face down. Each turn both players turn their top card * over; the higher takes both, aces high. When the two are the same rank it is war: each lays three cards face down and * turns a fourth over, and the higher of those two takes everything laid, and a tie goes to war again, as many times as it * takes. A player who cannot finish a war, with fewer than four cards to lay in it, loses; both unable, the one who runs * out first, with fewer cards, loses, and level it is a draw. The * winner of a turn puts the cards they won under their pile, shuffled, so a game cannot run in circles for ever. The game * ends when one player holds every card, or after the number of turns it was set up for, when the player holding more cards * wins and equal piles are shared. * * Pure: every function returns a new game and leaves the one given alone. */ /** The cards a player lays in a war before the one turned up. * * @example * ```ts * import { WAR_FACE_DOWN } from "@johnmorrisdotca/toranpu/war"; * console.log(WAR_FACE_DOWN); * ``` */ export declare const WAR_FACE_DOWN = 3; /** How a rank counts at War: the ace highest, then king down to two. * * @param card - The physical card or card id to read, draw or play. * @returns How a rank counts at War: the ace highest, then king down to two. * * @example * ```ts * import { warRank } from "@johnmorrisdotca/toranpu/war"; * * console.log(warRank("AS")); * ``` */ export declare function warRank(card: CardId): number; /** 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. `computers` says, one a seat, which seats a computer plays; the third argument is unused. * * @param size - The game’s length or size, as defined by its table specification. * @param players - The player names in seat order. * @param _language - An unused legacy language argument retained for compatibility. * @param dealt - The numeric seed used to deal the game. * @param computers - Flags by seat: true where a computer controls that seat. * @returns 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. `computers` says, one a seat, which seats a computer plays; the third argument is unused. * * @example * ```ts * import { CARD_GAME_TABLES } from "@johnmorrisdotca/toranpu"; * import { startWar } from "@johnmorrisdotca/toranpu/war"; * * const names = Array.from({ length: CARD_GAME_TABLES.war.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * console.log(startWar(CARD_GAME_TABLES.war.defaultSize, names, undefined, 42)?.phase); * ``` */ export declare function startWar(size: number, players: readonly string[], _language?: unknown, dealt?: number, computers?: readonly boolean[]): WarGame | null; /** Every move the table may make now: turning the cards over, until the game is over. * * @param game - The current native game; applying a move returns a new state. * @returns Every move the table may make now: turning the cards over, until the game is over. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import { warMoves } from "@johnmorrisdotca/toranpu/war"; * * const names = Array.from({ length: CARD_GAME_TABLES.war.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("war", { players: names, seed: 42 })!; * console.log(warMoves(game)); * ``` */ export declare function warMoves(game: WarGame): WarMove[]; /** Whether something is the one move War has. * * @param value - The unknown value to validate. * @returns Whether something is the one move War has. * * @example * ```ts * import { isWarMove } from "@johnmorrisdotca/toranpu/war"; * * console.log(isWarMove({ turn: true })); * ``` */ export declare function isWarMove(value: unknown): value is WarMove; /** 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. * * @param game - The current native game; applying a move returns a new state. * @param move - The native move to validate or apply. * @returns 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. * * @example * ```ts * import { CARD_GAME_TABLES, newGame, rulesFor } from "@johnmorrisdotca/toranpu"; * import { playWar } from "@johnmorrisdotca/toranpu/war"; * * const names = Array.from({ length: CARD_GAME_TABLES.war.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("war", { players: names, seed: 42 })!; * console.log(playWar(game, rulesFor("war").moves(game)[0]!)?.moves.length); * ``` */ export declare function playWar(game: WarGame, move: WarMove): WarGame | null; /** 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. * * @param game - The current native game; applying a move returns a new state. * @returns 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. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import { warWinners } from "@johnmorrisdotca/toranpu/war"; * * const names = Array.from({ length: CARD_GAME_TABLES.war.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("war", { players: names, seed: 42 })!; * console.log(warWinners(game)); * ``` */ export declare function warWinners(game: WarGame): number[];