From 865babb3570c8e89bb38f947784ab94d4ea64449 Mon Sep 17 00:00:00 2001 From: henddher Date: Wed, 12 Oct 2022 19:28:22 -0500 Subject: [PATCH] Replace ExitTypeclass (XYZExit) with specified Typeclass in prototype. --- evennia/contrib/grid/xyzgrid/tests.py | 2 +- evennia/contrib/grid/xyzgrid/xymap_legend.py | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/evennia/contrib/grid/xyzgrid/tests.py b/evennia/contrib/grid/xyzgrid/tests.py index 19ee6e302f..2592b6b963 100644 --- a/evennia/contrib/grid/xyzgrid/tests.py +++ b/evennia/contrib/grid/xyzgrid/tests.py @@ -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()]) diff --git a/evennia/contrib/grid/xyzgrid/xymap_legend.py b/evennia/contrib/grid/xyzgrid/xymap_legend.py index bcffbb241c..bbf4eab7b3 100644 --- a/evennia/contrib/grid/xyzgrid/xymap_legend.py +++ b/evennia/contrib/grid/xyzgrid/xymap_legend.py @@ -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():