chance-deck usage

node v5.12.0
version: 0.1.0
endpointsharetweet
// initialize chance instance const chance = require('chance').Chance(); // add this module as mixin const chance_deck = require('chance-deck'); chance.mixin({ deal: chance_deck.deal });
chance.deal({ hands: 4 })
// remaining cards are put in `stock` chance.deal({ hands: 3, per_hand: 5 });
// you can distribute anything with `deal()` chance.deal({ deck: 'abcdefghijklmnopqrstuvwxyz'.split(''), hands: 2 });
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] === '🃟';
Loading…

no comments

    sign in to comment