fix numbered target cmd parse
This commit is contained in:
parent
f88b68dac6
commit
a7f8529610
2 changed files with 12 additions and 1 deletions
|
|
@ -397,7 +397,7 @@ class NumberedTargetCommand(COMMAND_DEFAULT_CLASS):
|
||||||
"""
|
"""
|
||||||
super().parse()
|
super().parse()
|
||||||
self.number = 0
|
self.number = 0
|
||||||
if hasattr(self, "lhs"):
|
if getattr(self, "lhs", None):
|
||||||
# handle self.lhs but don't require it
|
# handle self.lhs but don't require it
|
||||||
count, *args = self.lhs.split(maxsplit=1)
|
count, *args = self.lhs.split(maxsplit=1)
|
||||||
# we only use the first word as a count if it's a number and
|
# 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.obj2.location = self.char1
|
||||||
self.call(general.CmdGive(), "2 Obj = Char2", "You give two Objs")
|
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):
|
def test_mux_command(self):
|
||||||
class CmdTest(MuxCommand):
|
class CmdTest(MuxCommand):
|
||||||
key = "test"
|
key = "test"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue