- Notifications
You must be signed in to change notification settings - Fork0
A delightful card dealing companion for your digital table.
License
svyatov/card_dealer
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
CardDealer is your go-to gem for creating, shuffling, and dealing decks of cardswith ease. Whether you're building a poker night app or a virtual bridge club,CardDealer has got you covered. Enjoy customizable deck options, smoothshuffling algorithms, and simple yet powerful deck manipulation tools that bringthe classic card game experience to life.
Install the gem and add to the application's Gemfile by executing:
$ bundle add card_dealer
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install card_dealer
To create a standard 52-card deck, use theCardDealer::BuildDeck.standard52
method:
deck=CardDealer::BuildDeck.standard52putsdeck.cards
To create a standard 36-card deck, use theCardDealer::BuildDeck.standard36
method:
deck=CardDealer::BuildDeck.standard36putsdeck.cards
To create a custom deck of cards, use theCardDealer::BuildDeck.custom
method.You can specify the number of decks, cards per suit, ranks, and suits:
deck=CardDealer::BuildDeck.custom(decks:2,cards_per_suit:5,ranks::highest,suits:%w[cd])putsdeck.cards
TheCardDealer::Deck
class provides methods for shuffling and dealing cards:
deck=CardDealer::BuildDeck.standard52deck.shufflehand=deck.deal(5)putshand
You can also burn cards before dealing:
deck=CardDealer::BuildDeck.standard52deck.shufflehand=deck.deal(3,burn:1)putshand
To burn cards without dealing, just pass0
as the number of cards to deal:
deck=CardDealer::BuildDeck.standard52deck.shufflehand=deck.deal(0,burn:1)putshand
Burned cards are stored within the deck and can be accessed viaburned_cards
method:
deck=CardDealer::BuildDeck.standard52deck.shuffledeck.deal(0,burn:10)putsdeck.burned_cards
To encode a deck of cards as a binary string, use theCardDealer::BinaryDeck.encode
method.This is useful if you'd like to store a deck of cards in a database, cache, or a file:
deck=CardDealer::BuildDeck.standard52encoded_deck=CardDealer::BinaryDeck.encode(deck)# - or -encoded_deck=deck.to_binary_sputsencoded_deck
To decode a binary string into a deck of cards, use theCardDealer::BinaryDeck.decode
method:
encoded_deck="\x02\xCDP"# binary stringdecoded_deck=CardDealer::BinaryDeck.decode(encoded_deck)# - or -decoded_deck=CardDealer::Deck.from_binary(encoded_deck)putsdecoded_deck.cards
After checking out the repo, runbin/setup
to install dependencies. Then, runrake spec
to run the tests. You can also runbin/console
for an interactiveprompt that will allow you to experiment.
To install this gem onto your local machine, runbundle exec rake install
. Torelease a new version, update the version number inversion.rb
, and then runbundle exec rake release
, which will create a git tag for the version, pushgit commits and the created tag, and push the.gem
file torubygems.org.
Bug reports and pull requests are welcome on GitHub athttps://github.com/svyatov/card_dealer.
The gem is available as open source under the terms of theMIT License.
About
A delightful card dealing companion for your digital table.