import type { SpiderColumn, SpiderMove, SpiderTable } from "./spider.types.ts"; /** * THE RULES OF SPIDER, pure: every function returns a new table and leaves the * one it was given alone, as Klondike's and FreeCell's do, so a game is its * deal and its moves. * * The rules as the site plays them: * - Two decks, dealt into ten columns: fifty-four cards, one to each column in * turn, so the first four take six and the rest five, and only the top card * of each face up. The other fifty are the stock. * - A card may go onto any card one higher, of any suit, or into an empty * column. A run may move as a whole only if it is all one suit, in order. * - A full run of one suit, King down to Ace, is taken off the table by * itself. Eight of them win the game. * - A face-down card left on top of a column turns over by itself. * - The stock deals one card face up onto every column at once, five times in * all, and only while no column is empty. */ /** How many columns the tableau has. * * @example * ```ts * import { COLUMNS } from "@johnmorrisdotca/toranpu/spider"; * console.log(COLUMNS); * ``` */ export declare const COLUMNS = 10; /** How many ranks a suit has, ace to king. * * @example * ```ts * import { RANKS_A_SUIT } from "@johnmorrisdotca/toranpu/spider"; * console.log(RANKS_A_SUIT); * ``` */ export declare const RANKS_A_SUIT = 13; /** Full runs to make: two decks of four suits. * * @example * ```ts * import { RUNS_TO_WIN } from "@johnmorrisdotca/toranpu/spider"; * console.log(RUNS_TO_WIN); * ``` */ export declare const RUNS_TO_WIN = 8; /** Cards dealt to the columns before play; the rest are the stock. * * @example * ```ts * import { DEALT } from "@johnmorrisdotca/toranpu/spider"; * console.log(DEALT); * ``` */ export declare const DEALT = 54; /** How many cards two decks hold, which Spider is played with at any number of suits. * * @example * ```ts * import { DECK_SIZE } from "@johnmorrisdotca/toranpu/spider"; * console.log(DECK_SIZE); * ``` */ export declare const DECK_SIZE = 104; /** A card's suit, 0 to 3 in `SUITS` order. * * @param card - The packed card number from 0 to 51. * @returns A card's suit, 0 to 3 in `SUITS` order. * * @example * ```ts * import { suitOf } from "@johnmorrisdotca/toranpu/spider"; * * console.log(suitOf(0)); * ``` */ export declare const suitOf: (card: number) => number; /** A card's rank, 1 for an ace to 13 for a king. * * @param card - The packed card number from 0 to 51. * @returns A card's rank, 1 for an ace to 13 for a king. * * @example * ```ts * import { rankOf } from "@johnmorrisdotca/toranpu/spider"; * * console.log(rankOf(0)); * ``` */ export declare const rankOf: (card: number) => number; /** The suits a game of so many suits is played with, in `SUITS` order: spades; spades and hearts; all four. * * @param suits - The allowed suits. * @returns The suits a game of so many suits is played with, in `SUITS` order: spades; spades and hearts; all four. * * @example * ```ts * import { suitsFor } from "@johnmorrisdotca/toranpu/spider"; * * console.log(suitsFor(1)); * ``` */ export declare function suitsFor(suits: number): number[]; /** The hundred and four cards of a game of so many suits, sorted: each suit's thirteen, as many times as fill two decks. * * @param suits - The allowed suits. * @returns The hundred and four cards of a game of so many suits, sorted: each suit's thirteen, as many times as fill two decks. * * @example * ```ts * import { spiderDeck } from "@johnmorrisdotca/toranpu/spider"; * * console.log(spiderDeck(1).length); * ``` */ export declare function spiderDeck(suits: number): number[]; /** Deal a shuffled deck (card numbers, the first dealt first) into a table. * * @param deck - The deck in its current order; the input is left unchanged. * @returns Deal a shuffled deck (card numbers, the first dealt first) into a table. * * @example * ```ts * import { dealSpider, spiderDealOfSeed, spiderDeckOf } from "@johnmorrisdotca/toranpu/spider"; * * console.log(dealSpider(spiderDeckOf(spiderDealOfSeed(42, 1), 1)!).stock.length); * ``` */ export declare function dealSpider(deck: readonly number[]): SpiderTable; /** How many cards on top of a column are one suit and in order, all face up: the most a carry can take. * * @param column - The column with its face-down count and bottom-to-top cards. * @returns How many cards on top of a column are one suit and in order, all face up: the most a carry can take. * * @example * ```ts * import { runLength } from "@johnmorrisdotca/toranpu/spider"; * * console.log(runLength({ down: 0, cards: [4, 3, 2] })); * ``` */ export declare function runLength(column: SpiderColumn): number; /** Whether the stock can deal now: cards left, and no column empty. * * @param table - The native solitaire table; move helpers leave the input unchanged. * @returns Whether the stock can deal now: cards left, and no column empty. * * @example * ```ts * import { canDeal, dealSpider, spiderDealOfSeed, spiderDeckOf } from "@johnmorrisdotca/toranpu/spider"; * * const table = dealSpider(spiderDeckOf(spiderDealOfSeed(42, 1), 1)!); * console.log(canDeal(table)); * ``` */ export declare function canDeal(table: SpiderTable): boolean; /** The table after a move, or null where the rules refuse it. * * @param table - The native solitaire table; move helpers leave the input unchanged. * @param move - The native move to validate or apply. * @returns The table after a move, or null where the rules refuse it. * * @example * ```ts * import { dealSpider, playSpider, spiderDealOfSeed, spiderDeckOf } from "@johnmorrisdotca/toranpu/spider"; * * const table = dealSpider(spiderDeckOf(spiderDealOfSeed(42, 1), 1)!); * console.log(playSpider(table, { kind: "deal" })?.stock.length); * ``` */ export declare function playSpider(table: SpiderTable, move: SpiderMove): SpiderTable | null; /** * How many cards a carry from one column onto another takes, where it is not * the player's to say: onto a card, the one count whose foot is one lower. * Into an empty column any count up to the run would do, so none is chosen here. * * @param table - The native solitaire table; move helpers leave the input unchanged. * @param from - The source position or source state specified by this API. * @param to - The destination position or state specified by this API. * @returns The unique legal carried-card count for a nonempty destination, or null when there is no such count or the destination is empty and the player must choose. * * @example * ```ts * import { countOnto, dealSpider, spiderDealOfSeed, spiderDeckOf } from "@johnmorrisdotca/toranpu/spider"; * * const table = dealSpider(spiderDeckOf(spiderDealOfSeed(42, 1), 1)!); * console.log(countOnto(table, 0, 1)); * ``` */ export declare function countOnto(table: SpiderTable, from: number, to: number): number | null; /** Whether all eight runs are made. * * @param table - The native solitaire table; move helpers leave the input unchanged. * @returns Whether all eight runs are made. * * @example * ```ts * import { dealSpider, spiderDealOfSeed, spiderDeckOf, spiderWon } from "@johnmorrisdotca/toranpu/spider"; * * const table = dealSpider(spiderDeckOf(spiderDealOfSeed(42, 1), 1)!); * console.log(spiderWon(table)); * ``` */ export declare function spiderWon(table: SpiderTable): boolean; /** Whether every card is dealt and face up: from here the game plays itself out, where it can (`finishingMoves`). * * @param table - The native solitaire table; move helpers leave the input unchanged. * @returns Whether every card is dealt and face up: from here the game plays itself out, where it can (`finishingMoves`). * * @example * ```ts * import { allShowing, dealSpider, spiderDealOfSeed, spiderDeckOf } from "@johnmorrisdotca/toranpu/spider"; * * const table = dealSpider(spiderDeckOf(spiderDealOfSeed(42, 1), 1)!); * console.log(allShowing(table)); * ``` */ export declare function allShowing(table: SpiderTable): boolean; /** Every move the rules allow from a table, one of each (the whole run into an empty column), for a stuck-game check. * * @param table - The native solitaire table; move helpers leave the input unchanged. * @returns Every move the rules allow from a table, one of each (the whole run into an empty column), for a stuck-game check. * * @example * ```ts * import { dealSpider, movesFrom, spiderDealOfSeed, spiderDeckOf } from "@johnmorrisdotca/toranpu/spider"; * * const table = dealSpider(spiderDeckOf(spiderDealOfSeed(42, 1), 1)!); * console.log(movesFrom(table).slice(0, 5)); * ``` */ export declare function movesFrom(table: SpiderTable): SpiderMove[];