mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 12:56:30 +01:00
Merge pull request #3487 from InspectorCaracal/patch-moveobjcmd
Fix traceback in new NumberedTargetCommand
This commit is contained in:
commit
ccd6b365e9
2 changed files with 12 additions and 1 deletions
|
|
@ -397,7 +397,7 @@ class NumberedTargetCommand(COMMAND_DEFAULT_CLASS):
|
|||
"""
|
||||
super().parse()
|
||||
self.number = 0
|
||||
if hasattr(self, "lhs"):
|
||||
if getattr(self, "lhs", None):
|
||||
# handle self.lhs but don't require it
|
||||
count, *args = self.lhs.split(maxsplit=1)
|
||||
# we only use the first word as a count if it's a number and
|
||||
|
|
|
|||
|
|
@ -134,6 +134,17 @@ class TestGeneral(BaseEvenniaCommandTest):
|
|||
self.obj2.location = self.char1
|
||||
self.call(general.CmdGive(), "2 Obj = Char2", "You give two Objs")
|
||||
|
||||
def test_numbered_target_command(self):
|
||||
class CmdTest(general.NumberedTargetCommand):
|
||||
key = "test"
|
||||
|
||||
def func(self):
|
||||
self.msg(f"Number: {self.number} Args: {self.args}")
|
||||
|
||||
self.call(CmdTest(), "", "Number: 0 Args: ")
|
||||
self.call(CmdTest(), "obj", "Number: 0 Args: obj")
|
||||
self.call(CmdTest(), "1 obj", "Number: 1 Args: obj")
|
||||
|
||||
def test_mux_command(self):
|
||||
class CmdTest(MuxCommand):
|
||||
key = "test"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue