As for mapping what you parse from the commandline into your data structures, I found it very useful to write callbacks and associate them with commands. So, the "examine" command would have a function associated with it that would be called whenever the "examine" command was entered. This is sometimes known as a dispatch table. Although I worked primarily with the command, there is no reason why you cannot extend that idea to a function that will, given the name of something, return back a list of objects that map to that something. You could even have that function constrain based on various criteria, such as what the player can see, what the player has in inventory, etc.
I have a node here regarding the testing of this game. The "Adventure" link links to the a PDF written by Donald Knuth dissecting the original Adventure game. It's a C translation of the original game in Fortran, but it has a number of good ideas.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
In reply to Re: Writing a text adventure in Perl
by dragonchild
in thread Writing a text adventure in Perl
by Trag
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |