card-removal
What it does
card-tracker is a dependency free library which keeps running track of the remaining cards left in the deck and the current blackjack card count. Cards can either be added or removed to your tracker. Both common module and umd compatible for the browser.
Install
Node:
npm install card-tracker
Browser Script: Go to unpkg.com/card-tracker@version/dist where 'version' is latest released version. Insert either the index.umd.js or index.umd.min.js as a script.
Usage
Initialize
var CardTracker = ;var cardTracker = 1; // number of card decks
Methods:
- removeCards
- addCards
- updateCardValues
/* removeCards and addCards take a space seperated string of cards represented by two characters, value and suitexample ten clubs - tc, ace spades - as*/cardTracker;
Attributes:
- decks - Initial number of decks used
- numberOfCardsLeft
- remainingCards
- cardCount - Current card count
- trueCardCount - cardCount / number of decks (where number of decks =
numberOfCardsLeft / 52
cardTrackerdecks // 1cardTrackercardCount // -3 as 3 high cards removedcardTrackernumberOfCardsLeft // 49 (52 - 3)cardTrackerremainingCards // {'as': 0, 'ad': 1, ... 'ts': 1, 'td': 0, ... 'jc': 0}cardTrackertrueCardCount // -3 / (49 / 52) = 3.18 cardTrackercardTrackernumberOfCardsLeft // 52cardTrackerreamainingCards // {... 'td': 3, ...}cardTrackercardCount // 0 since adding high card increases count cardTracker; cardTracker;cardTrackercardCount // -100;
Notes
- Atempt to remove a card that has a count of zero will give a warning and be ignored.
- Default card count values are as follows:
- cards 2 - 6: +1 count
- 7-9: 0 count
- 10-a: -1 count
- Using
updateCardValues
to update a card value will not update the existing count, but will use the new value for the count going forward