C# in my RPG: the Fusion of Hobbies

This is a preview of my attempt at realizing one of my New Year’s Resolutions: “Merge my love of programming with my love of roleplaying.”  I have done this in the past with simple stuff like dice rollers and Excel spreadsheets with tons of clunky VB Script.  This time I am putting it right on the bleeding edge.  I want to learn WPF (Windows Presentation Foundation) and improve my DB skills so I figured I would take a stab at it by designing an application for use with D&D.

Combat Manager Preview
Combat Manager Preview

Platform

I am actually going to try to support both 3.5 and 4e, which I just started working into the db (database) side of things.  I am providing a demo of the program so you can see where I am going with this as far as layout is concerned.  It obviously doesn’t do anything yet, since I am still architecting the database.  Here are some details about the program:

  • Mad Brew Labs’ D&D Combat Manager v0.1
  • Languages: C#, XAML, LINQ, XML
  • Operating System: Windows XP SP3 & Windows Vista
  • Platform: Microsoft .NET 3.5 with SP1 (WPF & SQL Express)

If the program ever becomes desirable for Mac and Linux users, I am afraid they are out of luck.  At least until Mono catches up with all the features I am using from .NET 3.5.  Even then, I do not know if I would want to attempt the conversion, but I might be willing to open source the project so some other ambitious person can.

Goals

I have several goals in mind for this piece of software.  I want to be able to support more than one combat at a time, so this means making the data persistent.  This means I needed some method of storing said data, so I am going with MS SQL Server Express.  It packs a lot power and I can incorporate it into the app.

Eventually I want the program to be able to export and import encounters.  This will of course mean developing an XML schema, which will be cake once I finish the SQL Express schema.  However, I am designing the db with expansion in mind, since at some point I might want to create a suite of tools.  So I will need separate import/export files for characters, monsters, and spells.

I also want users to be able to add custom conditions and modifiers to the Combat Manager, which means I’ll need a tool that will allow end users to modify database entries.  And of course another XML format for portability and sharing.

Allow the creation of campaigns for which each combat is associated.  This will be more important if I happen to expand into a suite of tools.  Players, encounters, and other resources can all be associated with a campaign.

I want to develop a creature catalog that can store the basic info about monsters (attack, defense, initiative modifier, hit points, etc.).  This will mean providing an interface for to allow users to modify the tables concerning monsters.

The following is a breakdown of how I would like several operations to function:

Add Character

  • Select characters from the campaign library
  • Select monsters from the creature catalog
  • Allow groupings for simplified initiatives (like all monsters of a type)

Roll Initiative

  • Select init modifier from characters/monsters data
  • Generate a random number between 1-20 and then add init mod for each individual or group
  • Give an option to use highest or lowest init mod for groups
  • Arrange icons in init order and highlight first character/group

Track Rounds

  • Place each round in its own tab
  • Simplified descriptions are placed in action row
  • Hover over action row to read full details
  • New effects are place in a new row under the affect instance
  • Effects are highlighted with colors for easy reference
  • Previous turns are “grayed out”
  • Enter DM notes for each turn
  • A picture associated with the current turn is placed in upper right corner

New Round

  • If effect ends, a notification pops up on the beginning of the turn
  • If a save is needed, it prompts for a saving throw
  • If an ability recharges, a notification pops-up
  • Dead/Incapacitated subjects “sink” to the bottom of the display

Progress

I am admittedly not very far along on this project.  Below is a picture that shows how far along I am developing the database.  You can see by how I am setting the db up that it will allow for expansion (if not demand it).  I am also pretty new the db side of programming.  I usually like working with simple or medium complexity queries and then manipulate the data further within the app (which is bad practice!).

Data Model
Data Model

However, I think the initiated will see that this will require some complex queries with elegant joins that work with variables.  If I were to deploy this as a web app, I would certainly make use of DTS (SSIS), stored procedures, and views, which might be something I approach in the future.

If you take a look at the demo, you will see that I need to tweak how objects are resized.  I plan on allowing areas to have scrollbars in the event a user wants to make the window smaller than the design allows.

Future

I am pretty swamped with projects, for RPGs or otherwise, but this is definitely something I would like to see come to fruition (the more quality pieces in my software developing portfolio the better!).  However, I don’t have a timeline, as there are just too many factors at play.  Just keep checking back for more updates.

Oh, and I will be releasing the app free for personal use under some Creative Commons license that is yet to be specified.

Download Prototype

Listening to: Disarmonia Mundi – Mind Tricks – Resurrection Code

7 thoughts on “C# in my RPG: the Fusion of Hobbies

  1. NICE! looking forward to it. While I don’t know C# per se; as a 10+ year Perl haXXorz I have a deep appreciation for homebrew coding. Heck, more than 1/2 my dissertation was code I wrote. heh…

    Here’s a thought – take it or junk it. Code this up for use on a blackberry or iPhone. Since I don’t game with laptops or even books at the game table, an iPhone app or something similar would be no nuisance at all… and this app would be great to have on board.

    jonathan’s last blog post..Existere – A Map of RPG Blogs & Gaming Cons

  2. I won’t touch the iPhone (because of all bullshit surrounding developing for it), but turning it into a Blackberry app would be sweet, especially when my company switches to Verizon (cause then I can trade in my 8830 for Storm!).

    I’ve also thought about doing a lite version in Flash that would be cross platform, I’d just skip data storage.

    Looking into the Blackberry API…

  3. Sounds awesome and useful. Have fun, and good luck!

    As someone who’s been combining my love of roleplaying with my love of PHP, let me just say: enjoy all the hours scouring through rulebooks to figure out if you need to double the amount of code just to account for one exception that only happens when a certain class mixes with a certain creature type on an odd-numbered tuesday.

    Hey, we wouldn’t do it if it weren’t fun. Right? ..Right?

  4. @Swordgleam: Yeah, I have travelled down that path before using VB Script and Excel. But yeah, I wouldn’t do it if I didn’t have fun solving problems like that. Gives you a sense of satisfaction at the end of the day.

  5. @Micah: I don’t like using synthetic identifiers because I don’t like dealing with data doesn’t have obvious meaning. I think I can go without and have things able to be renamed as long as I do some accurate checks and correct UPDATE commands.

    I would go 4e, if that is what I thought I’d be playing more of in the future. What I am doing to begin with, is working on a “simple mode” for the tracker where all of the data is basically volatile and isn’t saved. You just click on a “new row” icon and then start entering values. Then you can reorder however you like. Once that is ironed out, all the basic functionality is done, and I can do the “advanced mode.”

    So the plan is to introduce a simplified form of the tracker with few features and then progressively add features. In fact I think I might break out MS Project and create a timeline (though all the time would be “relative” since I’m not really on a schedule) of milestone releases where requisite features are added in the appropriate order.

    Thanks for the input. I too have converted some traditional philosophy to apply to software development in Occam’s Razor: Pluralitas non est ponenda sine neccesitate or Entities should not be multiplied unnecessarily. But since this case deals with my hobby and not my career, I’m not too worried about biting off more than I chew.

  6. We decided to punt on a lot of the technical crunch for Obsidian Portal. I never really wanted to make a character generator or combat tracker, and instead just wanted a campaign management system.

    In the end, I think it was the right decision. Swordgleam is right that you end up having to take into account crazy rules and situations that are extremely rare. I have a lot of respect for tools like PCGen that seem to work on even the craziest character combos.

    Here are some quick pointers from one tabletop gaming programmer to another. As always, take them or leave them:

    1) Create “synthetic identifiers” for your DB tables. Essentially, an integer ID column for each table, and use that as your primary key. Using things like encounter name will almost always get you into trouble, since people will want to change that stuff. Completely artificial IDs are the way to go.

    2) I would suggest going either/or on 3.5 vs 4e, and my gut says 4e. I think 4e will be easier to tackle since there’s less of an emphasis on continuing effects and almost everything is either “to the end of combat” or “until your next turn” So, you could cover the vast majority of effects without a lot of custom coding. 3.5 combats are complicated!

    3) Mercilessly cut features. Writing something like this in your own time is very difficult, and the worst possible outcome is to get so bogged down that you never release anything. So, concentrate on the smallest possible core you can and get that out. Get some feedback from users (and yourself) and then continue from there. This is related to what I’ve termed The Ontological Argument Applied to Programming: The worst piece of working software is still better than the best piece of vaporware.

    Anyways, this comment seems to have suffered from feature creep already, so I should just shut up. Good luck with your tool, and make sure it can output combat results in HTML…for easy pasting into your favorite campaign management website 😉

Leave a Reply

Your email address will not be published.