Fun with databases
I know I’ve mentioned a couple of times this RoR project that I’ve been toying with for a while. The most interesting thing for me so far has been that I’ve had to learn a lot about database structure and modeling before I’ve even gotten to the Rails part.
It’s amazing how much abstraction our brains are capable of that we don’t even realize until we sit down and try to represent a “simple” concept for a computer database. What I’ve been working with for this project has been a way to store the Disciplines and talents from the Earthdawn system in a database - the eventual product being an app that serves as a management tool of sorts, allowing for simple editing, display, and adding new talents or Disciplines into the system. It’s possible that somewhere down the line this could be a community thing, but for now, I’m mostly interested in it for my own use. From my days of playing Earthdawn, I always felt that the Discipline system was fairly simple. Hah. Then I tried to figure out how to represent a Discipline as a row in a table, and all hell broke loose.
For those of you who are unfamiliar with Earthdawn, let me see if I can summarize how the Discipline system works. Basically, a Discipline is a “class” that a character in the RPG may take that defines what role it plays in the party. This might include the warrior or wizard, familiar roles we all know and love (*cough*) from AD&D or WoW. Each Discipline consists of at most 15 circles, though many may have as few as 8 or 12. These circles represent levels of advancement and talent availability. The first circle gives the Adept (or follower of the Discipline) access to a specific 6 talents (differing by Discipline, of course), which he must learn in order for the magical nature of the Discipline to take hold. After some adventuring, he may then advance to second circle. From third to eighth circles, he gains access to 2 talents. At ninth circle (if the Discipline has one), he again gains access to 3 talents. And from 10th through 15th circles, 2 talents become available at each circle. From a database perspective, this is no simple object; a Discipline has available to it anywhere from 21 to 36 unique talents, each only available at a specific circle.
And that’s not all. Starting at 4th circle, each Discipline also gains at least 1 “circle ability” (though often more are available in the upper circles). These abilities may be simple bonuses to physical or spell defense, or they may be full unique abilities in their own right, much like a talent ability in WoW (Mortal strike or Improved Sap, for example). The tricky part is that the simple bonuses to defenses can and often are repeated at various circles.
Ah, and lets not forget the talents themselves. Each talent is based upon a specific attribute (perception or initiative, for example), though there are a few exceptions which have no base attribute. Each talent also must be specified as either an action (taking your entire combat turn) or not, requiring karma, and have an associated amount of strain taken to use the talent. In addition, some talents are considered “discipline” when used by a member of certain Disciplines, representing the fact that some Disciplines have a closer tie to specific talents than others; for example, a warrior or swordmaster is far more familiar with the nature of Melee weapons than a wizard or elementalist.
Having written the above, is it not impossible to conclude that the Discipline system is fairly complex? It’s funny how adaptable the human mind is. At any rate, I think I’ve finally figured out how to represent the data in a database. Essentially, we have three objects: talents, Disciplines, and circle abilities. Talents and Disciplines are related to each other in that each talent may belong to any number of Disciplines, and each Discipline has many talents; this relationship also makes relevant the circle at which a talent is available for a specific Discipline and whether or not that talent is “discipline” for that Discipline (I’m sorry, I know the wording is confusing). Additionally, circle abilities and Disciplines are related similarly, in that each circle ability may belong to many Disciplines (often more than once in the same one) and each Discipline has many circle abilities. To prevent ambiguity, we also need to know the circle(s) at which an ability is available to a specific Discipline.
In database terms, this leaves me with 5 tables: talents, disciplines, circle_abilities, and the two “join” tables to facilitate the “has and belongs to many” relationships: disciplines_talents and circle_abilities_disciplines. Rails is apparently going to make things a little sticky, because it doesn’t like join tables to have any extra information; it wants each row in disciplines_talents to contain a talent and a Discipline, for example, but I need to have each row containing the circle and a field indicating whether or not that combination is “discipline” as well. I think there may be a way around the problem, but I guess we’ll see.
Anyway, if anyone’s actually still reading, I just wanted to try and put what I’ve done into words. The whole thing has turned out to be much more complicated than I had originally thought, and I haven’t even gotten to the Rails part, but I’m proud that I’ve figured out this much on my own, with very little knowledge of databases at all. If any of you actually know much about databases and want to correct my logic, please feel free; I’m fairly certain that I’ve got things settled right, but I have to concede that I’ve probably missed something.
M. E. Patterson
January 18th, 2006
2 years, 10 months ago
Actually, that all sounds pretty reasonable. Earthdawn is a nasty complex system as far as computerizing it is concerned. But then, take a look at the database behind, say, the ETools application for D&D 3.5. You’ve got classes, prestige classes, skills, feats (some restricted to races, classes, other feats, skill ranks, base stat ranks, etc.) and then you have spells, spell progressions, and then someone goes and creates a prestige class that doesn’t play nice with the standard rules (like lets an arcane caster behave like a cleric with spontaneous casting!).
Anyway, my point is that RPG systems are notoriously over-complex when it comes to trying to interpret them for a computer.