The RPG module is nearing an official 'Alpha' release. There are still a few things to flesh out, and I'll go over them in some detail soon. Here are some notes for fleshing out Attributes, which will be required before creating Actions and Modifiers. After those three sections of code have been finished, we should be ready to make some test game platforms!
Attributes
Attributes are defined by types, and may be overridden by descendant types. Objects will inherit the attributes of all its parent types. The default value of an attribute will be set by the type.
Still TODO for Attributes
- define simple attribute classes: integer, string (which may use filters). These will be defined by a module hook, for easy extensibility.
- create table to store attribute classes:
- class (corresponding to class of attribute -- integer/string/etc)
- name (such as strength, color, etc.)
- other columns? look at cck field widgets. not sure if things like required are appropriate here, but we can work that out.
- when a new attribute type is defined, a new table, with the name of ('rpg_type_attribute_' . $class), will be dynamically created to store:
- type (corresponding to rpg type)
- default value (will be assigned to objects of this type)
- other columns defined by the attribute class (such as min, max, filter, etc.) -- these are set by an array in the attribute class hook
- dynamically create table to store attribute values for objects, with the name of ('rpg_attribute_' . $class)
- rid (corresponding to rpg object id)
- value (given initial value of type's default value)
- any other columns required by the attribute class
- finish form to create attributes for rpg types. include a dropdown of already defined types, so the attributes may be overridden or added to another type
- on the rpg type attributes admin screen, show a table of all defined attributes, including a section with inherited types (which may be overridden simply by adding that attribute manually from a drop down on the add attribute screen)
- rewrite rpg_get/set to grab attribute values (exclusively? name will be the only required 'attribute', the rest defined through this system)
- on the rpg object add/edit screen, add form elements for all defined & inherited attributes, filling in the default values accordingly. similar to cck fields, the elements are defined by the appropriate attribute class hooks.
- for testing purposes, we'll also just list all attribute values on the object viewing screen. later, we'll have theme functions that will be able to theme them the way needed (leaving some attributes hidden if needed). actually, might be nice, following cck, to also have admin drop-downs to build an object view, as well as allowing theme overriding.
This article is cross-posted at the Games, and game APIs Drupal Group.
Aaron Winborn
DrupalRPG.org -- Home of the RPG Module for Drupal

