Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Deck

Hierarchy

Index

Constructors

Properties

cards: Set<Card>
deckPile: Card[]
discardPile: Card[] = []
heldPile: Card[] = []

Accessors

  • get discardedCards(): Card[]
  • get heldCards(): Card[]
  • get remainingCards(): Card[]
  • get remainingLength(): number
  • The current number of cards remaining in the deck pile

    Returns number

  • get totalLength(): number
  • The total number of all cards belonging to this deck, regardless of what pile they are currently in

    Returns number

Methods

  • Add a new Card to the deck, placing at the end of the given pile (defaults to "deck").

    Note: Does not confirm that the Card does not already belong to a deck before adding.

    Parameters

    Returns void

  • discard(card: Card): any
  • discardAllHeld(): void
  • Moves all currently held cards to the discard pile

    Returns void

  • draw(count?: number): Card[]
  • Draw the given number of cards, place them in the held pile, and return the drawn cards

    Parameters

    • count: number = 1

    Returns Card[]

  • drawFromBottom(count?: number): Card[]
  • Draw the given number of cards from the bottom of the deck pile, place them in the held pile, and return the drawn cards

    Parameters

    • count: number = 1

    Returns Card[]

  • drawToDiscard(count?: number): Card[]
  • Draw the given number of cards, place them in the discard pile, and return the drawn cards

    Parameters

    • count: number = 1

    Returns Card[]

  • drawToDiscardFromBottom(count?: number): Card[]
  • Draw the given number of cards from the bottom of the deck, place them in the discard pile, and return the drawn cards

    Parameters

    • count: number = 1

    Returns Card[]

  • Finds all cards in the deck matching the given filtering function

    const aces = deck.findCards((card) => card.rank === ace);
    

    Parameters

    Returns Card[]

  • Finds the given card and returns an object representing its current location (pile, and index in that pile)

    Parameters

    Returns CardLocation

  • Merge the given deck into this one, moving all cards belonging to the given deck into this deck.

    Parameters

    Returns void

  • remove(card: Card): void
  • Removes a card from the deck entirely.

    Note: Does not confirm that the card belongs to this deck before removing.

    Parameters

    Returns void

  • shuffleAll(): void
  • Moves all cards back to the deck pile and shuffles the deck

    Returns void

  • shuffleDeckAndDiscard(): void
  • Moves all cards in the discard back to the deck and shuffles the deck

    Returns void

  • shuffleDiscard(): void
  • Shuffles the cards in the discard pile and then places them at the end of the deck

    Returns void

  • shuffleRemaining(): void

Generated using TypeDoc