fix CmdCreate bugs
This commit is contained in:
parent
7a7416b084
commit
e143f47edd
3 changed files with 31 additions and 7 deletions
|
|
@ -660,7 +660,13 @@ class CmdCreate(ObjManipCommand):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
obj, errors = obj_typeclass.create(
|
obj, errors = obj_typeclass.create(
|
||||||
name, caller, home=caller, aliases=aliases, report_to=caller, caller=caller
|
name,
|
||||||
|
account=caller.account,
|
||||||
|
location=caller,
|
||||||
|
home=caller,
|
||||||
|
aliases=aliases,
|
||||||
|
report_to=caller,
|
||||||
|
caller=caller,
|
||||||
)
|
)
|
||||||
if errors:
|
if errors:
|
||||||
self.msg(errors)
|
self.msg(errors)
|
||||||
|
|
|
||||||
|
|
@ -726,23 +726,34 @@ class TestAccount(BaseEvenniaCommandTest):
|
||||||
class TestBuilding(BaseEvenniaCommandTest):
|
class TestBuilding(BaseEvenniaCommandTest):
|
||||||
def test_create(self):
|
def test_create(self):
|
||||||
typeclass = settings.BASE_OBJECT_TYPECLASS
|
typeclass = settings.BASE_OBJECT_TYPECLASS
|
||||||
name = typeclass.rsplit(".", 1)[1]
|
typename = typeclass.rsplit(".", 1)[1]
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdCreate(),
|
building.CmdCreate(),
|
||||||
f"/d TestObj1:{typeclass}", # /d switch is abbreviated form of /drop
|
f"/d TestObj1:{typeclass}", # /d switch is abbreviated form of /drop
|
||||||
"You create a new %s: TestObj1." % name,
|
f"You create a new {typename}: TestObj1",
|
||||||
)
|
)
|
||||||
|
# confirm object was added to the room's contents
|
||||||
|
self.assertEqual(self.room1.contents[-1].name, "TestObj1")
|
||||||
self.call(building.CmdCreate(), "", "Usage: ")
|
self.call(building.CmdCreate(), "", "Usage: ")
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdCreate(),
|
building.CmdCreate(),
|
||||||
f"TestObj1;foo;bar:{typeclass}",
|
f"TestObj2;foo;bar:{typeclass}",
|
||||||
"You create a new %s: TestObj1 (aliases: foo, bar)." % name,
|
f"You create a new {typename}: TestObj2 (aliases: foo, bar).",
|
||||||
|
)
|
||||||
|
# confirm object was added to the caller's contents
|
||||||
|
self.assertEqual(self.char1.contents[-1].name, "TestObj2")
|
||||||
|
|
||||||
|
def test_create_characters(self):
|
||||||
|
"""verify creating DefaultCharacter-descendant objects works, for NPCs"""
|
||||||
|
self.call(
|
||||||
|
building.CmdCreate(),
|
||||||
|
"/d TestNPC:evennia.DefaultCharacter",
|
||||||
|
"You create a new DefaultCharacter: TestNPC",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_examine(self):
|
def test_examine(self):
|
||||||
self.call(building.CmdExamine(), "", "Name/key: Room")
|
self.call(building.CmdExamine(), "", "Name/key: Room")
|
||||||
self.call(building.CmdExamine(), "Obj", "Name/key: Obj")
|
self.call(building.CmdExamine(), "Obj", "Name/key: Obj")
|
||||||
self.call(building.CmdExamine(), "Obj", "Name/key: Obj")
|
|
||||||
self.call(building.CmdExamine(), "*TestAccount", "Name/key: TestAccount")
|
self.call(building.CmdExamine(), "*TestAccount", "Name/key: TestAccount")
|
||||||
|
|
||||||
self.char1.db.test = "testval"
|
self.char1.db.test = "testval"
|
||||||
|
|
|
||||||
|
|
@ -2588,7 +2588,14 @@ class DefaultCharacter(DefaultObject):
|
||||||
return ";".join([puppet, delete, edit])
|
return ";".join([puppet, delete, edit])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, key, account=None, **kwargs):
|
def create(
|
||||||
|
cls,
|
||||||
|
key,
|
||||||
|
account: "DefaultAccount" = None,
|
||||||
|
caller: "DefaultObject" = None,
|
||||||
|
method: str = "create",
|
||||||
|
**kwargs,
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Creates a basic Character with default parameters, unless otherwise
|
Creates a basic Character with default parameters, unless otherwise
|
||||||
specified or extended.
|
specified or extended.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue