Friday, January 16, 2015

Latchkey #64 - Parser Work

I went back and split the enormous parser function into bite-size pieces.  That way I just get to the verb first, and check for other things as necessary.  I figure, if the player types a command that in no way could reference barriers, there's no point in checking for barriers in the player's command, yet normally that's one of the first things to be checked.  This new way of putting the verb first might possibly reduce unnecessary steps, but at the very least it should make things easier to understand at a glance.  That parser command is big and nasty and I had trouble understanding what I coded, even with comments in place.  This new change isn't fully implemented yet, but the functions exist without syntax errors, so it's a start.

It ends up chopping the parser command into five functions: the main one that gets the verb, then one for checking barriers, one for checking items in the room, the one for checking items in the player's inventory, and one for checking direction words.  I'll also need to check for adjectives, which so far has been half coded in horrendous way, but that code should be scrapped and recreated in a smaller function, which will hopefully be easier and less confusing soon.  Maybe.

No comments:

Post a Comment