Skip to main content

Klondike

drawFromStock​

Draws a single card from the stock and places it in the discard pile. If the stock is empty, the discard pile is restored to the stock.

import { drawFromStock } from "toranpu";

drawFromStock(state)

Arguments​

  • state (Interface): The game state

Returns​

(Void) undefined


getCanMoveFromDiscard​

Checks if a card can be moved from the discard to the tableau or foundation.

import { getCanMoveFromDiscard } from "toranpu";

getCanMoveFromDiscard(state, destination)

Arguments​

  • state (Interface): The game state.
  • destination (Union): The destination to move the card to.

Returns​

(Boolean) true if the move is valid, false otherwise.


getCanMoveFromSource​

Checks if a card can be moved from a source to a destination.

import { getCanMoveFromSource } from "toranpu";

getCanMoveFromSource(state, source, destination)

Arguments​

  • state (Interface): The game state.
  • source (Union): The source to move the card from.
  • destination (Union): The destination to move the card to.

Returns​

(Boolean) true if the move is valid, false otherwise.


getCanMoveFromTableau​

Checks if cards can be moved from the tableau to the foundation or another tableau column.

import { getCanMoveFromTableau } from "toranpu";

getCanMoveFromTableau(state, source, destination)

Arguments​

  • state (Interface): The game state
  • source (Interface): The source of the cards
  • destination (Union): The destination of the cards

Returns​

(Boolean) true if the cards can be moved, false otherwise.


getCanPlaceOnTableau​

Checks if cards can be placed on the tableau

import { getCanPlaceOnTableau } from "toranpu";

getCanPlaceOnTableau(state, cards, colIndex)

Arguments​

  • state (Interface): The game state
  • cards (Array): The cards to place
  • colIndex (Number): The index of the tableau column

Returns​

(Boolean) true if the cards can be placed, false otherwise


getIsNeutralCard​

Checks if a card is neutral. See solveNeutral for more information about neutral cards.

import { getIsNeutralCard } from "toranpu";

getIsNeutralCard(state, card)

Arguments​

  • state (Interface): The game state
  • card (Type): The card for which to check if it is neutral

Returns​

(Boolean) true if the card is neutral, false otherwise


getIsWinningState​

Checks if the game is won.

import { getIsWinningState } from "toranpu";

getIsWinningState(state)

Arguments​

  • state (Interface): The game state.

Returns​

(Boolean) true if the game is won, false otherwise.


getSourceCards​

Get cards from a source

import { getSourceCards } from "toranpu";

getSourceCards(state, source)

Arguments​

  • state (Interface): The game state
  • source (Union): The source of the cards

Returns​

(Type) The cards from the source


getTableauCards​

Gets a list of cards from the tableau. Does not remove the cards from the tableau.

import { getTableauCards } from "toranpu";

getTableauCards(state, columnIndex, deckIndex)

Arguments​

  • state (Interface): The game state
  • columnIndex (Number): The index of the column to get cards from
  • deckIndex (Number): The starting index of the deck to get cards from

Returns​

(Type) A list of cards from the tableau.


moveFromDiscard​

Move a card from the stock to the tableau or foundation.

import { moveFromDiscard } from "toranpu";

moveFromDiscard(state, destination)

Arguments​

  • state (Interface): The game state.
  • destination (Union): The destination to move the card to.

Returns​

(Void) undefined


moveFromSource​

Moves a card from a source to a destination.

import { moveFromSource } from "toranpu";

moveFromSource(state, source, destination)

Arguments​

  • state (Interface): The game state.
  • source (Union): The source to move the card from.
  • destination (Union): The destination to move the card to.

Returns​

(Void) undefined


moveFromTableau​

Moves a card from the tableau to the foundation or another tableau column.

import { moveFromTableau } from "toranpu";

moveFromTableau(state, source, destination)

Arguments​

  • state (Interface): The game state
  • source (Interface): The source of the card
  • destination (Union): The destination of the card

Returns​

(Void) undefined


setupGame​

Setup a game of Klondike

import { setupGame } from "toranpu";

setupGame(seed)

Arguments​

  • seed (String): The seed to use for shuffling the deck

Returns​

(Interface) The game state


solveNeutral​

Recursively moves neutral cards from the tableau to the foundation.

A neutral card is a card that does not impact the ability of the player to win the game. For example, an Ace is always neutral, as it is the lowest card; no card can be placed on top of it in the tableau. Similarly, a nine is neutral if an eight of the opposite color is already on the foundation.

import { solveNeutral } from "toranpu";

solveNeutral(state)

Arguments​

  • state (Interface): The game state.

Returns​

(Void) undefined


solveNeutralStep​

Moves a neutral card form the tableau to the foundation, if possible. See solveNeutral for more information.

import { solveNeutralStep } from "toranpu";

solveNeutralStep(state)

Arguments​

  • state (Interface): The game state.

Returns​

(Boolean) true if a neutral card was moved, false otherwise.