ProjectMoon / ringmud

RingMUD Java Mud Server and Engine
http://ringmud.thermetics.net/
GNU Lesser General Public License v3.0
21 stars 5 forks source link

Commands API Update #9

Open ProjectMoon opened 14 years ago

ProjectMoon commented 14 years ago

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 commented 14 years ago

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

ProjectMoon commented 14 years ago

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 commented 14 years ago

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

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 commented 14 years ago

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