UPDATE: Here’s a link to Sam’s version of the game. It’s a little more polished then my initial implementation. I think he’s still planning to add more features. Anyway, nice work!
It has an object-oriented model that can be reused in other card games. Inheritance is used to add blackjack-specific logic to the basic deck and hand objects and implement the scoring method.
The Sinatra web framework was used to provide the underlying scaffolding to create the web application. I’ve used Sinatra for a few projects recently and been really pleased with it. It is lightweight and makes it possible to create web applications quickly and easily without making a lot of assumptions about how you are going to use it.
Sinatra supports the haml templating language, which is such a pleasure to use compared to most of the other templating languages I’ve used. It has a great asthetic and is clear and easy to understand, resulting in some beautiful code. It even lets you use regular Ruby code in a simple way.
I chose redis to persist the game data. Mostly, this decision was because I wanted to try out a new noSQL database, but redis seems a decent fit because it allows data to be stored as a list associated with a key. This is similar to the internal structure implemented in Ruby and operations like pop and push to move the cards from the deck to the player’s hand just work the way they should.
The source code for this game is managed using git and deployed with heroku and redis to go. I’ve been impressed with the heroku deployment platform. It fits right into the workflow, is free for small projects like this, and seems easily scalable once more capacity is needed.