I am working on putting together a simple text adventure in Java and am having problems, due to my lack of proper design. My basic setup goes something like this:
- Get line of input from user
- Tokenize the line, checking each word to make
sure it is in the 'language'.
- If they are, convert them to integers.
- Based on the first word (which has to be a verb, move, look, listen etc..)
Execute the proper method to handle the command (actionMove(), actionLook() etc..) Which handles the processing of the rest of the line.
Now my issue is, I have a Parser class that does the converting and checking. Now my current thought is to simply make the appropriate constants (ACTIN_MOVE, ACTION_LISTEN etc..) static and to make the parse method return the list of tokens and have the other class check to see which method to execute. This is the way I am probably going to do it right now, since I can't think of a better way to do it, and can't find much help in coding a text adventure. Everything I am finding is about using the different engines that have been built for it.
Somewhat Structured Thoughts