Replace ExitTypeclass (XYZExit) with specified Typeclass in prototype.

This commit is contained in:
henddher 2022-10-12 19:28:22 -05:00
parent 0e91c21488
commit 865babb357
2 changed files with 9 additions and 11 deletions

View file

@ -1522,4 +1522,4 @@ class TestCallbacks(BaseEvenniaTest):
# Two rooms and 2 exits.
self.assertEqual(mock_room_callbacks.at_object_creation.mock_calls, [mock.call(), mock.call()])
# self.assertEqual(mock_exit_callbacks.at_object_creation.mock_calls, [mock.call(), mock.call()])
self.assertEqual(mock_exit_callbacks.at_object_creation.mock_calls, [mock.call(), mock.call()])

View file

@ -401,8 +401,13 @@ class MapNode:
continue
exitnode = self.links[direction]
# TODO: Use specified Typeclass
exi, err = ExitTypeclass.create(
prot = maplinks[key.lower()][3].prototype
typeclass = prot.get("typeclass", "")
self.log(f" spawning/updating exit xyz={xyz}, direction={key} ({typeclass})")
Typeclass = class_from_module(typeclass,
fallback="evennia.contrib.grid.xyzgrid.xyzroom.XYZExit")
exi, err = Typeclass.create(
key,
xyz=xyz,
xyz_destination=exitnode.get_spawn_xyz(),
@ -410,15 +415,8 @@ class MapNode:
)
if err:
raise RuntimeError(err)
linkobjs[key.lower()] = exi
prot = maplinks[key.lower()][3].prototype
tclass = prot["typeclass"]
tclass = (
f" ({tclass})"
if tclass != "evennia.contrib.grid.xyzgrid.xyzroom.XYZExit"
else ""
)
self.log(f" spawning/updating exit xyz={xyz}, direction={key}{tclass}")
# apply prototypes to catch any changes
for key, linkobj in linkobjs.items():