|Home||TSR Reviews||Deconstructing B/X D&D||Adventure Generator!||B/X D&D Character Generator||Other||Contact||RSS Feed|
The test harness is structured into several files and directories:
This is the test harness itself.
This is where the generator classes are stored, both the included examples and the ones that you'll write yourself.
In the TestHarness/Generators directory, there are several interfaces.
These interfaces define the functions that the generator that you want to write must implement. The only types of generator that are documented at the moment are Dressing and Encounters, which use iTextGenerator and iEncounterGenerator respectively, so those two and the interfaces that they extend are probably the only ones that you need to worry about.
If you're a little confused, don't worry about it. It'll be clear soon, once we get all this exposition out of the way.
In subdirectories below TestHarness/Generators/, there are several example generator classes included which implement the interfaces mentioned above. You can use these examples as a basis for your own.
The only ones that are documented at the moment are Dressing and Encounters. Trying to write any other type of generator may be counterproductive at the moment, given the lack of documentation and the fluid nature of the code in those areas.
This is where any static data for your generator needs to be stored. This directory is arranged using the same structure as Generators/. Ie, the class TestHarness/Generators/Adventure/ExampleAdventure.php.inc would store any static data that it needed under TestHarness/Data/Generators/Adventure/ExampleAdventure/
This directory includes some utility headers to make your life easier.
Provides an includeAll($path) function, which will include all .php.inc files in the given directory (but not any subdirectories beneath it). You probably won't need to use this in your own code, but it is used by testharness.php to load all the generator classes.
Convenience functions for tabletop-style die rolling. d($num,$sides) will roll a given number of dice with the given number of sides, ie d(3,6) will rill 3d6 and return a result. Please note that the statistical spread of d(3,6) or rolling 3 actual 6-sided dice is very different than mt_rand(3,18), so please use the d() function whenever possible. Also included are some convenience functions for rolling a given die size, ie d4([$num]) etc.
This function will take a GD image (http://php.net/manual/en/book.image.php) and return an inline base64 encoded PNG <IMG> tag that you can echo. Please note that, for security reasons, the static data files may not be accessable if you link directly to them via HTML (they are at the moment, but I'm going to fix that at some point), so please emit any images that your generator needs to draw as inline base64 encoded PNGs using this function.
You shouldn't need to worry about images for encounter and dressing generators, though.
NOTE: Since it seems that IE doesn't like to play well with base64 encoding, this library is obsolete. We've implemented a timed dynamic image cache instead, and documentation will be forthcoming someday™.
Simple code, swiped from the www somewhere, that tests to see if the given string ends with the given substring. Mostly used to filename sanity checking, and you shouldn't need to use this in your own code.
Two functions: numberToWord($num), which will take an integer (ie 2) and return a word (ie two). numberToNd($num), which will take an integer (ie 1 or 2 or 3 or 4) and output the equivalent -th form (ie 1st, 2nd, 3rd, 4th).