Skip to content

Releases: theaccordance/card-dealer

v2.0.0

21 Apr 03:38
Compare
Choose a tag to compare

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.

0.1.3

05 Nov 22:46
Compare
Choose a tag to compare
0.1.3 Pre-release
Pre-release

Refactor and Redeploy of card-dealer npm.

  • Unpack and Shuffle methods for standard deck added
  • Mocha Unit Tests added
  • Readme added
  • TravisCI added to check build status