2.1.2 • Published 2 years ago
ts-playing-cards v2.1.2
ts-playing-cards
A simple package that enables the creation of playing cards and decks, to help you create card games!
Features
Features
- Cards
- Cards
- Four suits + 1 no-suit
SuitValues.CLUBSSuitValues.SPADESSuitValues.HEARTSSuitValues.DIAMONDS- Joker have
SuitValues.NO_SUIT(noSuit) - Use
Suit.availableSuits()to getSuitValuesstring values
- Card faces
- All face cards are implemented through
FaceValues - Use
FaceValues.availableFaces()to getFaceValuesstring values
- All face cards are implemented through
- Create cards
- Default constructor
new Card()returnsaceofclubs. - Optional object constructor with
SuitValues
new Card( { suit: SuitValues, face: FaceValues, } )- Optional object constructor with
string
new Card( { suit: 'hearts', face: 'six', face: FaceValues, } )- Optional object constructor with
string
new Card( { suit: 'hearts', face: 'six', } ) - Default constructor
- Compare color cards
card.suit.isRedorcard.suit.isBlack
- Compare face values
card.compare(Card)⇒ returnsRank.LOWER, Rank.EQUAL, Rank.HIGHER
- Deck and Pile
- Deck and Pile
- Three deck types
DeckType.STANDARD(52 cards)DeckType.STANDARD_JOKERS(54 cards) andDeckType.FORTY(40 cards).- Use
Deck.availableDecks()to getDeckTypestring values to create new decks
- Create decks
- Default constructor
new Deck()returns a standard 52 cards deck - Optional object constructor with
DeckType
new Deck( { deckType: DeckType, numberOfDecks: number, customCards: Card[], } )- Optional object constructor with
string
new Deck( { deckType: 'forty', numberOfDecks: number, customCards: Card[], } )deckTypedetermines deck typenumberOfDecksmultiplies the number of cards in a deck by the specified number of decks amountcustomCardscreates a deck with custom cards
- Default constructor
- Shuffle cards
deck.shuffle()
- Remove cards from end and beginning of deck
deck.removeCard()ordeck.removeCardFromBegin()
- Add cards to deck
deck.addCard(Card)
- Check remaining cards
deck.remainingCards
- Check empty decks
deck.isEmpty
Pilehas the same methods asDeck, but it's created without cards.