ringmud icon indicating copy to clipboard operation
ringmud copied to clipboard

Commands API Update

Open ProjectMoon opened this issue 15 years ago • 4 comments

The Commands API needs to be updated:

  1. Asynchronous Commands need to "push" their results, rather than the current odd inversion of control paradigm being used right now where a CommandResult is returned and then sent back to the client. Logic for sending data to clients as a result of a command should be encapsulated in CommandResult.
  2. Command Templates This is to replace the old crappy CommandParameters way of parsing commands. Currently, the MUD is coded in such a way that there cannot be any type of CommandSender besides Mobiles. Command Templates are a way to rectify this. An individual command will be able to specify what templates it supports, and the template will be passed as a parameter to the execute method. The CommandParameters class will have a method for parsing a template. It will continue to store its object and String parameter arrays, but the actual work of parsing command parameters will be the template's job.

Templates will have some generic form of command types, similar to what exists now. May need to use strings for passing options. shudder

ProjectMoon avatar Apr 04 '10 20:04 ProjectMoon

Commands are now "asynchronous." Now need to deal with adding command template capabilities.

ProjectMoon avatar Apr 12 '10 02:04 ProjectMoon

It may be useful to generalize CommandResult out to a "ServerMessage" class. This implies that the CommandResult is not tied to any one part of the system, but rather is used for sending data back to the client from anywhere.

ProjectMoon avatar Apr 14 '10 13:04 ProjectMoon

CommandTemplate thoughts: Expose a CommandTemplate annotation that takes as a single parameter a list entries. Each entry has the following:

  • String representing the syntax of the command and the variables to bind.
  • An array entry that gives Class and (optionally) Scopes for each variable
  • A third parameter that indicates the Scope of the variables.

Variable Scope and Grammar

Each variable to be bound in the syntax can either scoped ($) or unscoped (:). A variable declared with $name will use the Scope object defined in the third parameter as its source for WorldObjectSearch. A variable declared with :name will require its Scope to be defined in the bind list.

Sample Declaration

@CommandTemplate([
{ "get $item", [ Item.class ], Scope.ROOM },
{"get :item from $bag", [{Item.class, Scope.LOCAL}, { Inventory.class}, Scope.ROOM}
])

ProjectMoon avatar Jun 14 '10 20:06 ProjectMoon

Command Template system has been finished. Now to update all the commands.

ProjectMoon avatar Jul 03 '10 18:07 ProjectMoon