import type { CardId } from "../card-games.types.ts"; import type { CrazyEightsGame, CrazyEightsMove } from "./crazy-eights.types.ts"; /** * CRAZY EIGHTS: the rules, and nothing else. The old public-domain game the * commercial colour-card games are built on. * * Two to seven players; seven cards each for two, five for more, and the top * card of the stock turned up to start the discard pile (an eight turned up * goes back under the stock). On your turn, play a card that matches the top * card's suit or rank. Eights are wild: play one on anything and name the * suit that must follow. If you cannot play, draw one card; if it can be * played you may play it, and otherwise your turn is over. When the stock * runs out the discards under the top card are shuffled into a new one; when * there are none, a player who cannot play passes, and a hand in which every * player passes in turn is blocked. * * The first out wins the hand and scores what everybody else still holds: * fifty for an eight, ten for a picture card, one for an ace and the face * value for the rest. A blocked hand goes to whoever holds the least, and * they score the rest. The first to the game's size wins. * * Pure: every function returns a new game and leaves the one given alone. */ /** The rank that is wild in Crazy Eights. * * @example * ```ts * import { EIGHT } from "@johnmorrisdotca/toranpu/crazy-eights"; * console.log(EIGHT); * ``` */ export declare const EIGHT = 8; /** What a card left in hand is worth to the winner of the hand. * * @param card - The physical card or card id to read, draw or play. * @returns What a card left in hand is worth to the winner of the hand. * * @example * ```ts * import { crazyPoints } from "@johnmorrisdotca/toranpu/crazy-eights"; * * console.log(crazyPoints("8H")); * ``` */ export declare function crazyPoints(card: CardId): number; /** Seven cards each for two players, five for more. * * @param seats - The seat count or seat state supplied by this API. * @returns Seven cards each for two players, five for more. * * @example * ```ts * import { crazyHandSize } from "@johnmorrisdotca/toranpu/crazy-eights"; * * console.log(crazyHandSize(4)); * ``` */ export declare function crazyHandSize(seats: number): number; /** A hand as a player holds it: eights last, the rest by suit and rank. * * @param hand - The player’s held cards, or the hand number for a deal. * @returns A hand as a player holds it: eights last, the rest by suit and rank. * * @example * ```ts * import { sortCrazy } from "@johnmorrisdotca/toranpu/crazy-eights"; * * console.log(sortCrazy(["8H", "AS", "2C"])); * ``` */ export declare function sortCrazy(hand: readonly CardId[]): CardId[]; /** A new game of Crazy Eights for these players (one name a seat) at this size, dealt from the seed `dealt`, or null for a table Crazy Eights 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 Crazy Eights for these players (one name a seat) at this size, dealt from the seed `dealt`, or null for a table Crazy Eights 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 { startCrazyEights } from "@johnmorrisdotca/toranpu/crazy-eights"; * * const names = Array.from({ length: CARD_GAME_TABLES.crazyEights.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * console.log(startCrazyEights(CARD_GAME_TABLES.crazyEights.defaultSize, names, undefined, 42)?.phase); * ``` */ export declare function startCrazyEights(size: number, players: readonly string[], _language?: unknown, dealt?: number, computers?: readonly boolean[]): CrazyEightsGame | null; /** The card on top of the discard pile. * * @param game - The current native game; applying a move returns a new state. * @returns The card on top of the discard pile. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import { crazyTop } from "@johnmorrisdotca/toranpu/crazy-eights"; * * const names = Array.from({ length: CARD_GAME_TABLES.crazyEights.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("crazyEights", { players: names, seed: 42 })!; * console.log(crazyTop(game)); * ``` */ export declare function crazyTop(game: CrazyEightsGame): CardId; /** Whether this card may go on the pile now: an eight always; otherwise the suit to follow or the top card's rank. * * @param game - The current native game; applying a move returns a new state. * @param card - The physical card or card id to read, draw or play. * @returns Whether this card may go on the pile now: an eight always; otherwise the suit to follow or the top card's rank. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import { crazyMatches } from "@johnmorrisdotca/toranpu/crazy-eights"; * * const names = Array.from({ length: CARD_GAME_TABLES.crazyEights.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("crazyEights", { players: names, seed: 42 })!; * console.log(crazyMatches(game, game.hands[game.toPlay!]![0]!)); * ``` */ export declare function crazyMatches(game: CrazyEightsGame, card: CardId): boolean; /** The cards the player to move may play now: after drawing, only the card drawn. * * @param game - The current native game; applying a move returns a new state. * @returns The cards the player to move may play now: after drawing, only the card drawn. * * @example * ```ts * import { CARD_GAME_TABLES, newGame, rulesFor } from "@johnmorrisdotca/toranpu"; * import { crazyPlayable } from "@johnmorrisdotca/toranpu/crazy-eights"; * * const names = Array.from({ length: CARD_GAME_TABLES.crazyEights.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("crazyEights", { players: names, seed: 42 })!; * const rules = rulesFor("crazyEights"); * 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(crazyPlayable(game)); * ``` */ export declare function crazyPlayable(game: CrazyEightsGame): CardId[]; /** 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 { crazyEightsMoves } from "@johnmorrisdotca/toranpu/crazy-eights"; * * const names = Array.from({ length: CARD_GAME_TABLES.crazyEights.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("crazyEights", { players: names, seed: 42 })!; * console.log(crazyEightsMoves(game)); * ``` */ export declare function crazyEightsMoves(game: CrazyEightsGame): CrazyEightsMove[]; /** 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 { playCrazyEights } from "@johnmorrisdotca/toranpu/crazy-eights"; * * const names = Array.from({ length: CARD_GAME_TABLES.crazyEights.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("crazyEights", { players: names, seed: 42 })!; * console.log(playCrazyEights(game, rulesFor("crazyEights").moves(game)[0]!)?.moves.length); * ``` */ export declare function playCrazyEights(game: CrazyEightsGame, move: CrazyEightsMove): CrazyEightsGame | null; /** The highest score wins, once somebody reaches the game's size; level on it shares the win. * * @param game - The current native game; applying a move returns a new state. * @returns The highest score wins, once somebody reaches the game's size; level on it shares the win. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import { crazyEightsWinners } from "@johnmorrisdotca/toranpu/crazy-eights"; * * const names = Array.from({ length: CARD_GAME_TABLES.crazyEights.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("crazyEights", { players: names, seed: 42 })!; * console.log(crazyEightsWinners(game)); * ``` */ export declare function crazyEightsWinners(game: CrazyEightsGame): number[];