UNPKG

card-factory

Version:

A comprehensive library for card manipulation

44 lines 1.78 kB
import Card from "../card/card"; import Pile from "../pile/pile"; import { PileElementType, PileOptionsType } from "../../types/pile.types"; import { CardElementType } from "../../types/card.types"; import { DeckType } from "../../types/deck.types"; /** * A deck is all of the cards to be used in your game. * * Most Standard Playing Card games will only have one deck (52 cards) * * Players will have cards from this deck in their piles... draw piles, hands, discard piles, etc. Those are Piles. * * In a more advanced game, each player could be playing from separate decks, ex) Magic The Gathering * * Pass an argument of an array of Cards to build deck with cards added already. Or initiate a deck and use function addCards to populate cards. */ export default class Deck<T extends Card> implements DeckType<T> { private _cards; private _piles; private _graveyard; private _cardBuilder; pileElements: PileElementType<T>[]; constructor(cards: T[], cardBuilder?: (card: T) => CardElementType<T>); get cards(): T[]; /** * @param cards must be a singular item of class Card or an Array of class Card * @returns card will be added into the deck */ addCards: (cards: T | T[]) => void; /** * This will create a pile for draw piles, discard piles, hands. Anywhere cards can go! * @returns Piles */ createPile: (name: string, cards?: T[]) => Pile<T>; createPileElement: (name: string, cards?: T[], options?: Partial<PileOptionsType<T>>) => PileElementType<T>; /** * * @param card A singular item of class Card * @returns true if card was removed * @returns false if card was not found in deck */ removeCard: (card: T) => boolean; } //# sourceMappingURL=deck.d.ts.map