I'm working on a small online game where there is a need to store a reasonable amount of information about many (100+) different kinds of game objects.
I'm trying to decide whether to have this data generated by code or stored in some configuration file.
Data generation approach would be something like (in java-ish pseudo code):
(within a set of functions executed once at program startup)
....
// create grass terrain
grass=new GameObject();
grass.inheritProperties(generic_terrain);
grass.set(NAME,grass);
grass.set(MOVEABLE,true);
grass.set(MOVECOST,10);
grass.set(IMAGE_INDEX,1);
....
Whereas the config file approach would probably just use an XML-type format e.g.
(within terrain.xml file)
....
<terrain name="grass">
<inherit class="generic_terrain"/>
<property key="NAME" value="grass"/>
<property key="MOVABLE" value="true"/>
<property key="MOVECOST" value="10"/>
<property key="IMAGE_INDEX" value="1"/>
</terrain>
....
Some important points:
- This information is static each time the game game is run (i.e. does not change during execution)
- The property names (NAME, MOVECOST etc.) are a relatively small list but additional ones could be added over time
- It is safe to assume that it will only get changed by the development team (i.e. there is not a need for configuration to be managed outside the build process).
- It will need to be tweaked quite regularly during development for game balancing reasons (e.g. making units less/more powerful)
- There is a certain amount of "inheritance" of properties, i.e. in the example above grass needs to have all the standard properties defined by generic_terrain plus a few new additions/changes.
Which approach would be best for this situation? Any more importantly why?