Friends, Romans, countrymen, lend me your ears.
Today we bring tidings of updates to the Mercury Engine which will be nothing short of joyous to your tired ears. Handling commands from users - finally we have some code we can all appreciate.
Command Handling Basics
Let’s assume that you’re a Cosrinite. And let’s say you’ve entered a command into your favorite client (or if you’re old school, a command line interface). The Mercury Engine recognizes this sequence of letters as a potential command, and then passes it to the command handling subsystem. The command handling system parses the potential command by splitting the command into two parts. In particular, the sequence of letters is split at the first space. Note that the second part of the potential command may be empty - e.g., “say” would be split into “say” and “”.
In such cases, Cosrin may give you some profound insight:
The first part of the potential command is then compared to a set of registered commands. For commands from the user which are not valid (e.g., “saynoneshallpass”), the system returns a meaningful error message to the user, such as “You’ve typed an illegitimate command, how dare you!”
Well, maybe the message isn’t so elegant:
Should the first part match a registered command, the command handler subsystem sends both parts of the command text to the code associated with the identified command. This code then parses the command again (if necessary) and takes the requested action if the full command proves valid.
You can even use other languages in some commands:
Sometimes, the effect is not as you had hoped:
Command Handling Testing
In addition to handling commands, we have also continued our vertical-slicing ways with some testing to go along with a beautiful piece of code. Our testing includes checking valid and invalid commands and appropriate responses from some temporary command-handling code for commands which are fully valid.
Perhaps this post wasn’t as exciting as previous posts in terms of depth of content, but we hope that our audience is able to see that this update builds upon our previous efforts and starts to get into the “meat and potatoes” of how users primarily interact with the game.
Over the next few weeks, we plan to start tackling the following areas:
- Telnet Negotiation (some more riveting development work)
- User account creation and login experience
- Persistent data storage of user accounts
- Implementation of specific user commands as prioritized to support upcoming releases
Stay classy out there, and when the world has got you down, feel free to return to this post to help liven your day!