Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

chance-deck

Chance.js mixin for deck (playing cards) related functions

Install

npm install -S chance chance-deck

Usage

// initialize chance instanceconstchance=require('chance').Chance();// add this module as mixinconstchance_deck=require('chance-deck');chance.mixin({deal: chance_deck.deal});// profitchance.deal({hands: 4})/*{  '0': [ '🂺', '🃈', '🃉', '🂭', '🃍', '🂫', '🃑', '🃇', '🂥', '🂸', '🃕', '🂷', '🃁' ], '1': [ '🃔', '🃖', '🃅', '🃎', '🂨', '🂡', '🃗', '🃊', '🂲', '🂤', '🂦', '🃄', '🂩' ], '2': [ '🃛', '🃋', '🃒', '🂾', '🃆', '🂵', '🃞', '🃃', '🂶', '🃘', '🂱', '🂣', '🂴' ], '3': [ '🃝', '🃙', '🂹', '🂳', '🃚', '🂪', '🃂', '🂮', '🂧', '🂽', '🂻', '🂢', '🃓' ]}*/chance.deal({hands: 3,per_hand: 5});/*{ '0': [ '🃖', '🂽', '🃈', '🂢', '🂡' ], '1': [ '🃘', '🂷', '🂶', '🃃', '🃝' ], '2': [ '🃍', '🃆', '🂨', '🂣', '🃑' ], stock: [ '🃕', '🂪', '🂱', '🃁', ... ] // remaining cards}*/// you can distribute anything with `deal()`chance.deal({deck: 'abcdefghijklmnopqrstuvwxyz'.split(''),hands: 2});/*{ '0': [ 'n', 'g', 'o', 'm', 'e', 'd', 'p', 'k' ], '1': [ 'v', 't', 'j', 'c', 'f', 'w', 'u', 'i' ], '2': [ 'a', 'y', 'l', 'q', 'z', 'b', 'x', 'h' ], stock: [ 's', 'r' ]}*/// you can also use the built-in unicode decks as you wish// we have the standard 52-card deck and a full deck with 2 jokers (at index 52 and 53)chance.pickone(chance_deck.standard_deck);// '🃙'chance.pickset(chance_deck.full_deck,5);// [ '🃘', '🂦', '🃕', '🃓', '🂷' ]chance_deck.full_deck[52]==='🃏';chance_deck.full_deck[53]==='🃟';

Reference

Playing cards in Unicode - Wikiwand
Standard 52-card deck - Wikiwand

About

Chance.js mixin for deck (playing cards) related functions

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages