View Single Post
Old 10-26-2004, 07:58 PM   #2
Yui Unifex
Senior Member
 
Join Date: Apr 2002
Location: Florida
Posts: 323
Yui Unifex is on a distinguished road
Send a message via ICQ to Yui Unifex Send a message via AIM to Yui Unifex
Question

Of course there's a better way to do it =). Despite being a horrendous design decision, gigantic lists of switch and if statements don't cut it because they can't do partial matching of a command name.

You most likely want to store command objects in a dynamically extendable table. Of course it varies from mud to mud, but in the command object I keep an access control (so that the 'smite' command is not made available to normal players), the name of the command, a list of target specifications, and a function pointer or pointer to member function or delegate or code object or whatever so you can call the code you need when necessary.

The target specification is also very important and very overlooked. Many commands such as 'tell', 'kill', 'give', etc., are targetted at an element in the game. It should be the command dispatcher's job to locate those targets specified in the command string and pass them as an array when the actual command code is called into.

I refer you to the section on in my Aetas Concepts and Architecture document for some examples of how I define commands.
Yui Unifex is offline   Reply With Quote