card-dealer
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.0 • Public • Published

    Card Dealer

    Build Coverage Status CodeFactor npm latest version Known Vulnerabilities Bundle Size License

    A robust card-dealing JavaScript Class written in TypeScript

    Features

    • Use any card deck with the Dealer class
    • Shuffle deck into a random order
    • Draw cards for use
    • Discard cards without revealing them
    • Cut the deck
    • Included Decks
      • Standard 52 Playing Cards
      • Uno

    Installation

    npm

    $ npm install card-dealer --save

    yarn

    $ yarn add card-dealer

    Usage

    TypeScript

    import { Dealer, standardDeck } from "card-dealer";
     
    const dealer = new Dealer(standardDeck);

    JavaScript

    const Dealer = require("card-dealer/dealer");
    const standardDeck = require("card-dealer/decks/standard");
     
    const dealer = new cardDealer.Dealer(standardDeck);

    API

    const dealer = new Dealer(cardArray)

    Dealer() takes a deck of cards to use for a game & places it on the draw pile.

    dealer.shuffle()

    Randomizes the dealer's draw pile order using the Fisher-Yates shuffle algorithm.

    dealer.cut(index)

    Cuts the deck at the specified position in the deck, moving the bottom half to the top of the draw pile.

    dealer.draw(count)

    Returns the number of cards requested from the draw pile for use in the game.

    dealer.discard(count)

    Moves the number of cards specified from the draw pile to the discard pile without revealing the value to the game.

    dealer.reset()

    Resets the draw & discard piles to the default deck position.

    dealer.remainingCards()

    Returns a count for the remaining cards in the draw pile.

    Install

    npm i card-dealer

    DownloadsWeekly Downloads

    15

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    10.1 kB

    Total Files

    12

    Last publish

    Collaborators

    • theaccordance