Changing command functions from do_ to cmd_. Reads a little easier.

This commit is contained in:
Greg Taylor 2006-12-05 23:38:57 +00:00
parent 54fc8f2b76
commit 977864c649
4 changed files with 20 additions and 20 deletions

View file

@ -19,7 +19,7 @@ def handle(cdat):
command, or return an invalid command error. command, or return an invalid command error.
We're basically grabbing the player's command by tacking We're basically grabbing the player's command by tacking
their input on to 'do_' and looking it up in the GenCommands their input on to 'cmd_' and looking it up in the GenCommands
class. class.
""" """
session = cdat['session'] session = cdat['session']
@ -50,12 +50,12 @@ def handle(cdat):
if session.logged_in: if session.logged_in:
# If it's prefixed by an '@', it's a staff command. # If it's prefixed by an '@', it's a staff command.
if parsed_input['root_cmd'][0] != '@': if parsed_input['root_cmd'][0] != '@':
cmd = getattr(commands_general, 'do_%s' % (parsed_input['root_cmd'],), None ) cmd = getattr(commands_general, 'cmd_%s' % (parsed_input['root_cmd'],), None )
else: else:
parsed_input['root_cmd'] = parsed_input['root_cmd'][1:] parsed_input['root_cmd'] = parsed_input['root_cmd'][1:]
cmd = getattr(commands_staff, 'do_%s' % (parsed_input['root_cmd'],), None ) cmd = getattr(commands_staff, 'cmd_%s' % (parsed_input['root_cmd'],), None )
else: else:
cmd = getattr(commands_unloggedin, 'do_%s' % (parsed_input['root_cmd'],), None ) cmd = getattr(commands_unloggedin, 'cmd_%s' % (parsed_input['root_cmd'],), None )
if callable(cmd): if callable(cmd):
cdat['uinput'] = parsed_input cdat['uinput'] = parsed_input

View file

@ -9,7 +9,7 @@ Generic command module. Pretty much every command should go here for
now. now.
""" """
def do_look(cdat): def cmd_look(cdat):
""" """
Handle looking at objects. Handle looking at objects.
""" """
@ -67,7 +67,7 @@ def do_look(cdat):
for exit in con_exits: for exit in con_exits:
session.msg('%s(#%s)' %(exit.name, exit.id,)) session.msg('%s(#%s)' %(exit.name, exit.id,))
def do_quit(cdat): def cmd_quit(cdat):
""" """
Gracefully disconnect the user as per his own request. Gracefully disconnect the user as per his own request.
""" """
@ -75,7 +75,7 @@ def do_quit(cdat):
session.msg("Quitting!") session.msg("Quitting!")
session.handle_close() session.handle_close()
def do_who(cdat): def cmd_who(cdat):
""" """
Generic WHO command. Generic WHO command.
""" """
@ -105,7 +105,7 @@ def do_who(cdat):
session.msg(retval) session.msg(retval)
def do_say(cdat): def cmd_say(cdat):
""" """
Room-based speech command. Room-based speech command.
""" """
@ -120,7 +120,7 @@ def do_say(cdat):
session.msg(retval) session.msg(retval)
def do_version(cdat): def cmd_version(cdat):
""" """
Version info command. Version info command.
""" """
@ -130,14 +130,14 @@ def do_version(cdat):
retval += "-"*50 retval += "-"*50
session.msg(retval) session.msg(retval)
def do_time(cdat): def cmd_time(cdat):
""" """
Server local time. Server local time.
""" """
session = cdat['session'] session = cdat['session']
session.msg('Current server time : %s' % (time.strftime('%a %b %d %H:%M %Y (%Z)', time.localtime(),))) session.msg('Current server time : %s' % (time.strftime('%a %b %d %H:%M %Y (%Z)', time.localtime(),)))
def do_uptime(cdat): def cmd_uptime(cdat):
""" """
Server uptime and stats. Server uptime and stats.
""" """

View file

@ -7,7 +7,7 @@ import cmdhandler
Restricted staff commands. Restricted staff commands.
""" """
def do_dig(cdat): def cmd_dig(cdat):
""" """
Digs a new room out. Digs a new room out.
""" """
@ -22,7 +22,7 @@ def do_dig(cdat):
newroom.name = roomname newroom.name = roomname
newroom.type = "Room" newroom.type = "Room"
def do_nextfree(cdat): def cmd_nextfree(cdat):
""" """
Returns the next free object number. Returns the next free object number.
""" """
@ -34,7 +34,7 @@ def do_nextfree(cdat):
session.msg(retval) session.msg(retval)
def do_teleport(cdat): def cmd_teleport(cdat):
""" """
Teleports an object somewhere. Teleports an object somewhere.
""" """
@ -104,11 +104,11 @@ def do_teleport(cdat):
return return
session.msg("Teleported.") session.msg("Teleported.")
pobject.move_to(server, results[0]) pobject.move_to(server, results[0])
commands_general.do_look(cdat) commands_general.cmd_look(cdat)
#session.msg("Args: %s\n\rEqargs: %s" % (args, eq_args,)) #session.msg("Args: %s\n\rEqargs: %s" % (args, eq_args,))
def do_find(cdat): def cmd_find(cdat):
""" """
Searches for an object of a particular name. Searches for an object of a particular name.
""" """
@ -133,7 +133,7 @@ def do_find(cdat):
else: else:
session.msg("No name matches found for: %s" % (searchstring,)) session.msg("No name matches found for: %s" % (searchstring,))
def do_shutdown(cdat): def cmd_shutdown(cdat):
""" """
Shut the server down gracefully. Shut the server down gracefully.
""" """

View file

@ -5,7 +5,7 @@ import functions_db
Commands that are available from the connect screen. Commands that are available from the connect screen.
""" """
def do_connect(cdat): def cmd_connect(cdat):
""" """
This is the connect command at the connection screen. Fairly simple, This is the connect command at the connection screen. Fairly simple,
uses the Django database API and User model to make it extremely simple. uses the Django database API and User model to make it extremely simple.
@ -26,7 +26,7 @@ def do_connect(cdat):
uname = user.username uname = user.username
session.login(user) session.login(user)
def do_create(cdat): def cmd_create(cdat):
""" """
Handle the creation of new accounts. Handle the creation of new accounts.
""" """
@ -45,7 +45,7 @@ def do_create(cdat):
else: else:
functions_db.create_user(cdat, uname, email, password) functions_db.create_user(cdat, uname, email, password)
def do_quit(cdat): def cmd_quit(cdat):
""" """
We're going to maintain a different version of the quit command We're going to maintain a different version of the quit command
here for unconnected users for the sake of simplicity. The logged in here for unconnected users for the sake of simplicity. The logged in