I am creating a random item generator for my new gaming library RPG (thanks to monks for help with package yesterday). I have the program up and running, which works great, but I have a question on the data logic, if its one of the better ways?. The format/file storage is based from Andy Gryc's AutoRealm program and is detailed below.
I have not included the entire file, but the sample below easily gives its formating:
Where PARSEITEMNAME is the key, wgt is a weight out of 100, and the make-up-expression is an expression. The expression can contain option items in brackets [], and dice expressions in curly's {}. It can also contain markup, which I am converting over to XML. Data FormatPARSEITEMNAME [wgt] => make-up-expression => make-up-expression
DAGGER [75] => <table><tr><td><b>Dagger: </b></td></tr><tr><td>POMMEL +, BLADE</td></tr></table> => <table><tr><td><b>Knife: </b></td></tr><tr><td>POMMEL, + BLADE</td></tr></table> POMMEL => with a pommel that has a POMMELTIP and a GRIP with a HILT POMMELTIP => [ANIMAL head ][with 2 GEMTYPES for eyes ]tip made of META +L, => {GEMTYPES}s set in METAL, => {1d3+1} GEMTYPES set around a METAL base, GRIP => grip made of [ADJS] SOFTMATERIAL => grip made of [ADJH] METAL HILT => hilt made of METAL[ and 2 GEMTYPES set on the ends] => a pair of {ANIMAL}s forming the hilt made of METAL
The program is passed a Key which then gets the appropriate expression, and then parses that. If it finds another Key it then parses that and returns the results in place of the key.
Other features I would like to add is the ability to determine
top level Keys, so I can create a list from the data file,
along with the ability to create {1d3GEMS} and rather than
returning {1d3}GEMS it returns 1 to 3 GEMS.
Example:
- 2 Opals
.vs.
- Opal
- Diamond
The runtime script can be found at the following URL http://209.15.98.213/cgi-bin/items.pl
RPG is a library to aid Role Playing Gamers in creating, enhancing and running thier games. Modules under construction are RPG::Dice, RPG::RULGen, RPG::Name and RPG::Char. The data is for the RULGen module.
In reply to Data and Perl Logic by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |