import type { CardId, CardSuit } from "../card-games.types.ts"; import type { EuchreGame, EuchreMove, EuchrePlay } from "./euchre.types.ts"; /** * EUCHRE: the rules, and nothing else. * * Four players in two partnerships, partners across the table, with the * twenty-four cards from nine to ace. Five each, and the top of the four left * over turned up. Round the table from the dealer's left, each player may * order that card's suit as trumps (the dealer picks the card up and throws * one away) or pass; if all four pass, each may name another suit or pass, * and the dealer, last, must name one. In trumps the jack is the highest card * (the right bower), then the other jack of the same colour (the left bower, * which is a trump and no longer of its own suit), then ace, king, queen, ten * and nine. Follow suit if you can; the highest trump, or else the highest * card of the suit led, takes the trick. The partnership that made trumps * scores one for three or four tricks and two for all five; held to two or * fewer, it is euchred, and the other partnership scores two. The first to the * game's total wins. * * Pure: every function returns a new game and leaves the one given alone. */ /** How many play Euchre: four, in two partnerships. * * @example * ```ts * import { EUCHRE_SEATS } from "@johnmorrisdotca/toranpu/euchre"; * console.log(EUCHRE_SEATS); * ``` */ export declare const EUCHRE_SEATS = 4; /** The cards Euchre is played with: nine to ace of each suit. * * @example * ```ts * import { EUCHRE_DECK } from "@johnmorrisdotca/toranpu/euchre"; * console.log(EUCHRE_DECK); * ``` */ export declare const EUCHRE_DECK: readonly CardId[]; /** A seat's partnership: 0 for seats 0 and 2, 1 for seats 1 and 3. * * @param seat - The zero-based player seat. * @returns A seat's partnership: 0 for seats 0 and 2, 1 for seats 1 and 3. * * @example * ```ts * import { teamOf } from "@johnmorrisdotca/toranpu/euchre"; * * console.log(teamOf(3)); * ``` */ export declare function teamOf(seat: number): 0 | 1; /** The seat across the table. * * @param seat - The zero-based player seat. * @returns The seat across the table. * * @example * ```ts * import { partnerOf } from "@johnmorrisdotca/toranpu/euchre"; * * console.log(partnerOf(1)); * ``` */ export declare function partnerOf(seat: number): number; /** The seat that deals this hand: the first seat, then round to the left. * * @param deal - The deal number or dealing specification. * @returns The seat that deals this hand: the first seat, then round to the left. * * @example * ```ts * import { dealerOf } from "@johnmorrisdotca/toranpu/euchre"; * * console.log(dealerOf(0)); * ``` */ export declare function dealerOf(deal: number): number; /** The suit of the same colour: clubs and spades, diamonds and hearts. * * @param suit - The card suit to compare or name. * @returns The suit of the same colour: clubs and spades, diamonds and hearts. * * @example * ```ts * import { sameColour } from "@johnmorrisdotca/toranpu/euchre"; * * console.log(sameColour("H")); * ``` */ export declare function sameColour(suit: CardSuit): CardSuit; /** The suit a card belongs to once trumps are made: the left bower is a trump. * * @param card - The physical card or card id to read, draw or play. * @param trump - The current trump suit. * @returns The suit a card belongs to once trumps are made: the left bower is a trump. * * @example * ```ts * import { suitIn } from "@johnmorrisdotca/toranpu/euchre"; * * console.log(suitIn("JD", "H")); * ``` */ export declare function suitIn(card: CardId, trump: CardSuit | null): CardSuit; /** A card's height within its suit as the hand is played: ace high; in trumps the right bower, then the left, above everything. * * @param card - The physical card or card id to read, draw or play. * @param trump - The current trump suit. * @returns A card's height within its suit as the hand is played: ace high; in trumps the right bower, then the left, above everything. * * @example * ```ts * import { euchreHeight } from "@johnmorrisdotca/toranpu/euchre"; * * console.log(euchreHeight("JD", "H")); * ``` */ export declare function euchreHeight(card: CardId, trump: CardSuit | null): number; /** A hand sorted as a player holds it: by suit (trumps last once made), high cards to the right. * * @param hand - The player’s held cards, or the hand number for a deal. * @param trump - The current trump suit. * @returns A hand sorted as a player holds it: by suit (trumps last once made), high cards to the right. * * @example * ```ts * import { sortEuchre } from "@johnmorrisdotca/toranpu/euchre"; * * console.log(sortEuchre(["JD", "AH", "9C"], "H")); * ``` */ export declare function sortEuchre(hand: readonly CardId[], trump?: CardSuit | null): CardId[]; /** A new game of Euchre for these players (one name a seat) at this size, dealt from the seed `dealt`, or null for a table Euchre 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 Euchre for these players (one name a seat) at this size, dealt from the seed `dealt`, or null for a table Euchre 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 { startEuchre } from "@johnmorrisdotca/toranpu/euchre"; * * const names = Array.from({ length: CARD_GAME_TABLES.euchre.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * console.log(startEuchre(CARD_GAME_TABLES.euchre.defaultSize, names, undefined, 42)?.phase); * ``` */ export declare function startEuchre(size: number, players: readonly string[], _language?: unknown, dealt?: number, computers?: readonly boolean[]): EuchreGame | null; /** The cards the seat to play may lay on the trick: the suit led (the left bower counting as a trump) if it holds any. * * @param game - The current native game; applying a move returns a new state. * @returns The cards the seat to play may lay on the trick: the suit led (the left bower counting as a trump) if it holds any. * * @example * ```ts * import { CARD_GAME_TABLES, newGame, rulesFor } from "@johnmorrisdotca/toranpu"; * import { euchrePlayable } from "@johnmorrisdotca/toranpu/euchre"; * * const names = Array.from({ length: CARD_GAME_TABLES.euchre.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("euchre", { players: names, seed: 42 })!; * const rules = rulesFor("euchre"); * for (let setup = 0; setup < 100 && game.phase !== "playing" && game.phase !== "over"; setup += 1) { * const next = rules.play(game, rules.computer(game)); * if (next === null) throw new Error("Unexpected illegal setup move"); * game = next; * } * if (game.phase !== "playing") throw new Error("Setup did not reach playing"); * console.log(euchrePlayable(game)); * ``` */ export declare function euchrePlayable(game: EuchreGame): CardId[]; /** Who is taking a trick: the highest trump, or else the highest card of the suit led. * * @param trick - The cards and seats in the current trick. * @param trump - The current trump suit. * @returns Who is taking a trick: the highest trump, or else the highest card of the suit led. * * @example * ```ts * import { euchreTrickWinner } from "@johnmorrisdotca/toranpu/euchre"; * * console.log(euchreTrickWinner([{ seat: 0, card: "KH" }, { seat: 1, card: "JD" }, { seat: 2, card: "AH" }, { seat: 3, card: "QC" }], "H")); * ``` */ export declare function euchreTrickWinner(trick: readonly EuchrePlay[], trump: CardSuit): number; /** Every move the seat to play may make now; none once the game is over. * * @param game - The current native game; applying a move returns a new state. * @returns Every move the seat to play may make now; none once the game is over. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import { euchreMoves } from "@johnmorrisdotca/toranpu/euchre"; * * const names = Array.from({ length: CARD_GAME_TABLES.euchre.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("euchre", { players: names, seed: 42 })!; * console.log(euchreMoves(game)); * ``` */ export declare function euchreMoves(game: EuchreGame): EuchreMove[]; /** What a hand scores: one to the makers for three or four tricks, two for all five, and two to the other side when the makers take two or fewer. * * @param makers - Factories for the host’s custom card designs. * @param tricks - The number of tricks won. * @returns What a hand scores: one to the makers for three or four tricks, two for all five, and two to the other side when the makers take two or fewer. * * @example * ```ts * import { handPoints } from "@johnmorrisdotca/toranpu/euchre"; * * console.log(handPoints(0, 3)); * ``` */ export declare function handPoints(makers: 0 | 1, tricks: number): [number, number]; /** The game after that move, with the move added to its record, 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 that move, with the move added to its record, or null for a move the rules refuse. * * @example * ```ts * import { CARD_GAME_TABLES, newGame, rulesFor } from "@johnmorrisdotca/toranpu"; * import { playEuchre } from "@johnmorrisdotca/toranpu/euchre"; * * const names = Array.from({ length: CARD_GAME_TABLES.euchre.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("euchre", { players: names, seed: 42 })!; * console.log(playEuchre(game, rulesFor("euchre").moves(game)[0]!)?.moves.length); * ``` */ export declare function playEuchre(game: EuchreGame, move: EuchreMove): EuchreGame | null; /** The partnership with the higher score wins, both its seats. * * @param game - The current native game; applying a move returns a new state. * @returns The partnership with the higher score wins, both its seats. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import { euchreWinners } from "@johnmorrisdotca/toranpu/euchre"; * * const names = Array.from({ length: CARD_GAME_TABLES.euchre.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("euchre", { players: names, seed: 42 })!; * console.log(euchreWinners(game)); * ``` */ export declare function euchreWinners(game: EuchreGame): number[];