fix numbered target cmd parse

This commit is contained in:
Cal 2024-04-05 11:31:58 -06:00
parent f88b68dac6
commit a7f8529610
2 changed files with 12 additions and 1 deletions

View file

@ -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

View file

@ -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"