Pick a card, any card

Pick a card, any card is a "web service" that lets you draw a specified number of playing cards from a specified number of decks. Feel free to use it as long as you're not overtaxing this server.

Deal me a hand of card(s) from deck(s).
http://triskaideka.net/pick-a-card/any-card?num_cards=5&num_decks=1&game=poker&format=json

(Note that the code that displays the rectangular card layouts above is part of this page, not part of the service. Paste the example URL above into your browser's address bar to see exactly what kind of output you'll get.)

Parameters

Call the script using these parameters:

num_cards
A positive integer indicating how many cards to draw. Default is 1; upper limit is 500.
num_decks
A positive integer indicating how many decks to shuffle together. Default is 1; upper limit is 500. Or, this can be the string inf, meaning an infinite number of decks.
game
Either poker (the default) or pinochle.
num_jokers
A positive integer indicating how many jokers to include in each deck. Note that the total number of jokers is the value of num_jokers times the value of num_decks. Default is 0; upper limit is 500.
format
What format you want the response in. Default is text; other options are longtext, json, and xml.

About

The randomizer is Perl's List::Util; I'm not sure exactly what randomizer that uses, but it looks like regular old srand() or something like it. You shouldn't run a casino off this service (and not just for that reason), but it ought to be fine for recreational purposes.

I learned about Moose at the DC-Baltimore Perl Workshop 2013. I went home and started writing something with it, and this is what it turned into. Moose is great; it makes writing object-oriented Perl a lot less painful.

Download

You'll need to install Moose and Moose::Util::TypeConstraints (cpan install Moose). The other dependencies are part of the Perl core.