Skip to content

Commit

Permalink
Merge pull request #3373 from InspectorCaracal/cmdcreate-bugfix
Browse files Browse the repository at this point in the history
Fix CmdCreate bugs
  • Loading branch information
Griatch committed Jan 8, 2024
2 parents 7a7416b + e143f47 commit 58fad3d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
8 changes: 7 additions & 1 deletion evennia/commands/default/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,13 @@ def func(self):
continue

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:
self.msg(errors)
Expand Down
21 changes: 16 additions & 5 deletions evennia/commands/default/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,23 +726,34 @@ def test_quell(self):
class TestBuilding(BaseEvenniaCommandTest):
def test_create(self):
typeclass = settings.BASE_OBJECT_TYPECLASS
name = typeclass.rsplit(".", 1)[1]
typename = typeclass.rsplit(".", 1)[1]
self.call(
building.CmdCreate(),
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(),
f"TestObj1;foo;bar:{typeclass}",
"You create a new %s: TestObj1 (aliases: foo, bar)." % name,
f"TestObj2;foo;bar:{typeclass}",
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):
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(), "*TestAccount", "Name/key: TestAccount")

self.char1.db.test = "testval"
Expand Down
9 changes: 8 additions & 1 deletion evennia/objects/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2588,7 +2588,14 @@ def get_default_lockstring(
return ";".join([puppet, delete, edit])

@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
specified or extended.
Expand Down

0 comments on commit 58fad3d

Please sign in to comment.