import type { CardId } from "../card-games.types.ts"; import type { StackUpGame, StackUpMove } from "./stack-up.types.ts"; /** * STACK UP: the rules, and nothing else. * * Two to six players. The deck is 162 cards: twelve of each number from 1 to 12, and eighteen wilds. Each player is dealt * a stock pile (10, 15 or 20 cards, face down but for the top one), and the rest is the draw pile. On your turn you draw * up to five cards, then lay cards on the four building piles in the middle: a pile starts at 1 and goes up one at a time * to 12, and a wild stands for whatever the pile wants. You may lay a card from your hand, from the top of your stock, or * from the top of any of your four discard piles. A pile that reaches 12 is set aside, to be shuffled back into the draw * pile later. If you play your last hand card you draw five more at once. Your turn ends when you put one card from your * hand on one of your own discard piles. The first player to play the last card of their stock wins. If no card can be * drawn and nobody has played for a whole round, the game ends and the fewest stock cards left wins; level, they share it. * * Pure: every function returns a new game and leaves the one given alone. */ /** How many cards a hand is drawn up to. * * @example * ```ts * import { STACK_UP_HAND } from "@johnmorrisdotca/toranpu/stack-up"; * console.log(STACK_UP_HAND); * ``` */ export declare const STACK_UP_HAND = 5; /** The highest number on a card, and the length a building pile is finished at. * * @example * ```ts * import { STACK_UP_TOP } from "@johnmorrisdotca/toranpu/stack-up"; * console.log(STACK_UP_TOP); * ``` */ export declare const STACK_UP_TOP = 12; /** The wild card's name. * * @example * ```ts * import { STACK_UP_WILD } from "@johnmorrisdotca/toranpu/stack-up"; * console.log(STACK_UP_WILD); * ``` */ export declare const STACK_UP_WILD = "nw"; /** The four building piles in the middle, and the four discard piles each player has. * * @example * ```ts * import { STACK_UP_PILES } from "@johnmorrisdotca/toranpu/stack-up"; * console.log(STACK_UP_PILES); * ``` */ export declare const STACK_UP_PILES = 4; /** The whole deck of 162 cards, in a fixed order: 1 to 12 twelve times over, then the wilds. * * @example * ```ts * import { STACK_UP_DECK } from "@johnmorrisdotca/toranpu/stack-up"; * console.log(STACK_UP_DECK.length); * ``` */ export declare const STACK_UP_DECK: readonly CardId[]; /** The sizes of a stock pile a table is offered. * * @example * ```ts * import { STACK_UP_STOCKS } from "@johnmorrisdotca/toranpu/stack-up"; * console.log(STACK_UP_STOCKS); * ``` */ export declare const STACK_UP_STOCKS: readonly [10, 15, 20]; /** What a card counts for: its number 1 to 12, or 0 for a wild, which is whatever a pile wants. * * @param card - The card id to read. * @returns What a card counts for: its number 1 to 12, or 0 for a wild. * * @example * ```ts * import { stackUpValue } from "@johnmorrisdotca/toranpu/stack-up"; * console.log(stackUpValue("n07")); * ``` */ export declare function stackUpValue(card: CardId): number; /** What number a building pile wants next: one more than the cards on it. * * @param pile - The cards on the building pile. * @returns What number a building pile wants next: one more than the cards on it. * * @example * ```ts * import { stackUpWants } from "@johnmorrisdotca/toranpu/stack-up"; * console.log(stackUpWants(["n01", "nw"])); * ``` */ export declare function stackUpWants(pile: readonly CardId[]): number; /** Whether a card may go on a building pile: a wild always, a number when it is the one the pile wants. * * @param card - The card id to lay. * @param pile - The cards on the building pile. * @returns Whether a card may go on a building pile. * * @example * ```ts * import { stackUpFits } from "@johnmorrisdotca/toranpu/stack-up"; * console.log(stackUpFits("n01", [])); * ``` */ export declare function stackUpFits(card: CardId, pile: readonly CardId[]): boolean; /** A new game of Stack Up for two to six players with a stock pile of this size, dealt from the seed, or null for a table it is not offered for. * * @param size - The cards in each player's stock pile: 10, 15 or 20. * @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 Stack Up, or null. * * @example * ```ts * import { startStackUp } from "@johnmorrisdotca/toranpu/stack-up"; * console.log(startStackUp(15, ["Aki", "Ben"], undefined, 42)?.hands[0]?.length); * ``` */ export declare function startStackUp(size: number, players: readonly string[], _language?: unknown, dealt?: number, computers?: readonly boolean[]): StackUpGame | null; /** Every move the seat to play may make: each card that fits a building pile, from the hand, the stock or a discard pile; each card of the hand on each discard pile; and a pass when the hand is empty. * * @param game - The current native game; applying a move returns a new state. * @returns Every move the seat to play may make. * * @example * ```ts * import { stackUpMoves, startStackUp } from "@johnmorrisdotca/toranpu/stack-up"; * console.log(stackUpMoves(startStackUp(15, ["Aki", "Ben"], undefined, 42)!).length); * ``` */ export declare function stackUpMoves(game: StackUpGame): StackUpMove[]; /** Whether something is a move Stack Up has, by its shape. * * @param value - The unknown value to validate. * @returns Whether something is a move Stack Up has. * * @example * ```ts * import { isStackUpMove } from "@johnmorrisdotca/toranpu/stack-up"; * console.log(isStackUpMove({ pass: true })); * ``` */ export declare function isStackUpMove(value: unknown): value is StackUpMove; /** The game after a move, or null for a move the rules refuse. A card played from the last of a hand draws five more; the last card of a stock ends the game; a building pile of twelve is set aside. * * @param game - The current native game; applying a move returns a new state. * @param move - The move to apply. * @returns The game after a move, or null for a move the rules refuse. * * @example * ```ts * import { playStackUp, stackUpMoves, startStackUp } from "@johnmorrisdotca/toranpu/stack-up"; * * const game = startStackUp(15, ["Aki", "Ben"], undefined, 42)!; * console.log(playStackUp(game, stackUpMoves(game)[0]!)?.moves.length); * ``` */ export declare function playStackUp(game: StackUpGame, move: StackUpMove): StackUpGame | null; /** The seats that won a game that is over: the one who emptied their stock, or at a stuck table those with the fewest cards left; empty while it is being played. * * @param game - The current native game; applying a move returns a new state. * @returns The seats that won. * * @example * ```ts * import { stackUpWinners, startStackUp } from "@johnmorrisdotca/toranpu/stack-up"; * console.log(stackUpWinners(startStackUp(15, ["Aki", "Ben"], undefined, 42)!)); * ``` */ export declare function stackUpWinners(game: StackUpGame): number[];