Best of CF9: CFDungeon

This post is more than 2 years old.

Time for the next Best of ColdFusion 9 Entry - CFDungeon by Budd Wright. When I saw this entry came in, I decided to be selfish and keep it to myself. I love building games and I knew this entry would be cool. I wasn't prepared for just how cool it is. Ok - so what is it exactly? CFDungeon is an old school text based game. By that I mean everything in the game is textual. To play the game, you enter more commands. So for example, to walk from one place to another you type "north". If you can move north, then the game will tell you about the new location. Text-based games have a long history in computer entertainment, and I played many of them growing up. Some even approached art. (If you ever get a chance to play "A Mind Forever Voyaging" then you will see what I mean.) These games made up for their lack of fancy graphics with prose that was descriptive, engaging, and sometimes downright hilarious. Budd Wright has managed to recreate this in ColdFusion. And wait - this is where it really gets cool. Not only did he build a text-based game in ColdFusion 9 - he built it so you can easily write your own adventures, easily extend the parser, and oh yeah, he did it using freaking Excel files for data. That's stupid.... stupid cool.

When the game begins, you go through a simple character creation process. You have the choice between three different classes: Warrior, Thief, and Accountant. (Yes, Accountant.) After you've created your character you can then choose between two different quests. Both adventures are defines in a separate XLS file. The file defines the rooms, actors, objects, and other quest data. You should be able to build your own quest simply by following the pattern defined in the existing files.

I recommend playing the Old Hat quest. It's simple - can be done in 20 minutes or so - and really has the feel of an old Zork game. Some of the writing is just funny as heck. So for example:

And then...

Or even better...

And this was the absolute best:

So far I've just talked about the game itself (because, frankly, it was so damn fun), but the code itself is pretty darn sweet. It makes use of 100% script based CFCs, which I know not everyone likes, but I'm definitely in the "pro script" camp myself. I saw a few small things I'd probably change. He uses a method called writeLog which matches a built in function in ColdFusion 9. He got it work by scoping it but I'd urge folks to stay away from built in names.

His most critical mistake... and again... this has happened a few times already in this contest (!) is the use of \ in path names. Anyone not on Windows wants to do a search for "xls" to find all the paths and changes \ to /.

Another issue - and we can debate how critical this is - is the use of Application scoped components within his components. So for example, within inputHandler.cfc, you see this:

// Clear the last response Application.components.modules[ Session.module.name ].ClearResponse();

// Pass the input to the appropriate module handler Application.components.modules[ Session.module.name ].ReceiveInput( input );

While this works, it creates a dependancy to an Application location that may change in the future. This is exactly where something like ColdSpring can give you a hand.

Outside of that though - it's very good stuff. I'm just blown away. This is incredibly impressive and one of the coolest things I've seen ever. Would I deploy a production application that makes use of Excel sheets for data? Heck no. But you could drop a database in here in probably half an hour. Of course, you then actually lose some of the ease of updating (until you build an administrator).

I really, really, really like this entry. Great job Budd!

Download attached file.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Henry Ho posted on 12/11/2009 at 9:27 AM

cool, any live demo? :D

Comment 2 by Raymond Camden posted on 12/11/2009 at 9:31 AM

Just download it. :)

Comment 3 by Jody Fitzpatrick posted on 12/11/2009 at 9:49 AM

Do you remember "Oregon Trail" -- good times good times.

Comment 4 by Akbarsait posted on 12/11/2009 at 9:53 AM

Really Excellent Application, Just downloaded and playing the game and yes I have stopped my God of War in PS :-)

Comment 5 by Jonathan Gailing posted on 12/11/2009 at 11:48 AM

Brilliant!

Comment 6 by Justin Carter posted on 12/11/2009 at 5:19 PM

I'm guessing the Thief and the Accountant have pretty much the same storyline? Kidding :) That would be the Banker in the upcoming expansion pack.

Very neat idea though, great entry!

Comment 7 by Budd Wright posted on 12/11/2009 at 10:29 PM

Thanks, everyone! I'm glad you're enjoying CFDungeon -- it was a blast to write. For anyone who can't download it and play it themselves, my company DVS Interactive is also hosting it here: http://cfdungeon.dvsinterac...

Comment 8 by Joel Cox posted on 12/12/2009 at 12:41 AM

There is still a small, but active community that writes interactive fiction. Check out http://www.wurb.com/if/ for a list with ratings and download links. I was a bit skeptical when I first tried these, but some of them are written with a quality of prose and style equaling anything Infocom ever did. Try "Anchorhead" or "City of Secrets", you'll see what I mean.

Comment 9 by Joel Cox posted on 12/12/2009 at 12:47 AM

BTW, you need an interpreter to load of those games, and the site that I referenced is a little fuzzy about that. Check out http://www.ifwiki.org/index... for a list and links. "Gargoyle" is a nice one for Windows, and will load just about any game format.

Comment 10 by Ben Nadel posted on 12/12/2009 at 1:36 AM

While not the same thing, this makes me extremely nostalgic for Leisure Suit Larry.... :(

Comment 11 by Budd Wright posted on 12/12/2009 at 2:40 AM

Ben, I agree! Leisure Suit Larry was a fantastic adventure game series, along with the King's Quest series! Too bad the new Leisure Suit Larry games from recent years are all terrible!

Comment 12 by Ben Nadel posted on 12/13/2009 at 9:20 PM

Yeah, King's Quest was also a winner. I agree - the older school ones were better, when you could actually move around and type things. The newer ones are all about point-n-click and fancy graphics; to me, it always felt much less interactive.

Comment 13 by MikeG posted on 12/23/2009 at 1:35 AM

You can't be called a real adventurer until you have been eaten by a grue or have stuffed a babelfish in your ear!

Comment 14 by tof posted on 2/1/2010 at 5:21 AM

Let's not forget day of the tentacles, and the old Lucas arts games such as the monkey island and Indiana Jones franchises.

Comment 15 by LD2 posted on 3/18/2010 at 1:37 AM

Cool.. so a MUD created using CF?! Nifty!