Building up a Card Deck – Step 3: Putting Together the Deck

This is the third in a short series of posts about putting together a custom deck of cards from scratch. Step 1 was all about organizing the artwork in a meaningful way, and step 2 was about putting together a template to make the actual physical work easier. In this step, I’m going to talk a bit about how I put those two pieces together to make everything work.

My Tools

As in my prior post, I want to start by talking about my tools. The first, and most heavy-weight tool is perl. I’m running Cygwin, which is itself a full linux toolchain, perl and all. I’m fairly familiar with perl, so when I was thinking about how to start writing a script to do a lot of this for me, it was my first choice. Second, I’m using ImageMagick. I’ve yet to find a tool that does better command line image manipulation than ImageMagick, so it was the natural choice to do some automation. In this case, I am not using the perl bindings, rather using the regular command line interface. Finally, I ended up using pdftk to bundle everything together. After converting each image into a pdf from imagemagick, I have one final line to bring it all together into a single pdf, ready to go.

My Goals

My primary goal for this step was that all the work had to be automatic (hence the toolchain that I chose). If I’m going to make a deck with lots of cards, it would be far too time consuming to place them individually onto a deck one at a time. I also needed something that would be flexible – every game/component that I work on is slightly different, the cards are different sizes, resolutions, and need to fit onto different templates. So, whatever I did needed to be fairly hands-off, but flexible.

My Deck Creation Script

My first crack at a deck creation script basically took everything as command line arguments. Give it a card size, template, and a list of cards, and it would print out a series of ImageMagick commands to make a pdf with all the cards nicely arranged. As these commands got to be a bit longer, I decided to allow file or standard input instead of command line arguments, and before I realized it, I had a domain specific language on my hands – one that allowed quick creation of card decks.

A “program” in my language takes the card parameters and a list of cards and (as above) spits out all the necessary commands to make the decks. I started off doing it this way and stuck with it because it allowed a nice way to QC to make sure that all the commands looked right (I didn’t want to waste a bunch of time creating something that didn’t look right). If the commands looked right, I’d just pipe the whole thing to bash and away it would go.

I’ll admit at this point that my statement of “someone else could do this” somewhat falls apart. While I’m certain that anyone with a working knowledge of perl could recreate (or significantly improve) my script (there is nothing particularly novel or challenging about it), this ups the technological know-how needed to do the work. Suffice it to say, then, that this is the magic that makes the whole thing work for me.

Summary

Here’s a quick summary, in image form, for how the process works so far: