From 509e33f717fdbd455792f4cba3f2a583dc6100db Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Thu, 9 May 2019 21:06:35 +0000 Subject: [PATCH] Always pass parameters in commands When calling a command handler, pass a parameters object regardless of whether the command actually needs one. This normalizes the interface between command actions and their corresponding handler functions so they can be called through a generic interface in the future. --- mudpy/command.py | 6 +++--- share/command.yaml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mudpy/command.py b/mudpy/command.py index 250fb6f..a26906b 100644 --- a/mudpy/command.py +++ b/mudpy/command.py @@ -11,7 +11,7 @@ import unicodedata import mudpy -def chat(actor): +def chat(actor, parameters): """Toggle chat mode.""" mode = actor.get("mode") if not mode: @@ -271,14 +271,14 @@ def preferences(actor, parameters): actor.send(message) -def quit(actor): +def quit(actor, parameters): """Leave the world and go back to the main menu.""" if actor.owner: actor.owner.state = "main_utility" actor.owner.deactivate_avatar() -def reload(actor): +def reload(actor, parameters): """Reload all code modules, configs and data.""" if actor.owner: diff --git a/share/command.yaml b/share/command.yaml index cf3abec..382e47e 100644 --- a/share/command.yaml +++ b/share/command.yaml @@ -7,7 +7,7 @@ _desc: This is the standard library of command definitions. _lock: true -command.chat.action: mudpy.command.chat(actor) +command.chat.action: mudpy.command.chat(actor, parameters) command.chat.description: Enter and leave chat mode. command.chat.help: The chat command toggles chat mode. When in chat mode, all input is passed as a parameter to the say command, unless prepended by an @@ -64,12 +64,12 @@ command.preferences.help: If invoked with no parameters, all your current Examples:$(eol)$(eol) preferences$(eol) preferences prompt$(eol) preferences prompt $_(time)> -command.quit.action: mudpy.command.quit(actor) +command.quit.action: mudpy.command.quit(actor, parameters) command.quit.description: Leave the World. command.quit.help: This will deactivate your avatar and return you to the main menu. -command.reload.action: mudpy.command.reload(actor) +command.reload.action: mudpy.command.reload(actor, parameters) command.reload.administrative: true command.reload.description: Reload modules and data. command.reload.help: This will reload all python modules and read-only data -- 2.11.0