JOEZACK.COM Code Musings and Such

20Nov/080

JavaScript Deck of Cards

I wrote up a basic model for a 52 card deck of playing cards in JavaScript (using beloved Prototype. I plan on using it to make some very simple card games in the near future. I thought it'd be interesting to post this before I actually used it anywhere so I could take a look at how much it changed after I actually implemented it.

There's not much to see at the moment. You can just shuffle and get a card dump:

<html>
    <head>
        <title>JavaScript Deck of Cards</title>
        <script src="/common/prototype.js" type="text/javascript"></script>
        <script src="deck_of_cards_v1.js" type="text/javascript"></script>
    </head>
    <body>
        <script>
            d = new Deck();
            alert(d);
            d.shuffle();
            alert(d);
        </script>
    </body>
</html>

Download the code!
JavaScript Deck of Cards V1
Current Version

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)