From 283b6609341f2f250341077f55c8d3dda6392523 Mon Sep 17 00:00:00 2001 From: capital-G Date: Thu, 21 Sep 2023 22:07:50 +0000 Subject: [PATCH] deploy: 6e4aaeec9dfdc7f3fbe87c6139525fcdf10cec9f --- _modules/story_graph/engine.html | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/_modules/story_graph/engine.html b/_modules/story_graph/engine.html index 53f8c683..f558fd12 100644 --- a/_modules/story_graph/engine.html +++ b/_modules/story_graph/engine.html @@ -676,13 +676,22 @@

Source code for story_graph.engine

             ).afirst()
         # else return default out
 
-        if exit_door is None:
-            raise GraphDeadEnd()
-
-        try:
-            return (await exit_door.out_edges.order_by("?").select_related("in_node_door__node").afirst()).in_node_door.node  # type: ignore
-        except AttributeError:
-            raise GraphDeadEnd()
+ while True: + if exit_door is None: + raise GraphDeadEnd() + try: + return (await exit_door.out_edges.order_by("?").select_related("in_node_door__node").afirst()).in_node_door.node # type: ignore + except AttributeError: + if exit_door.is_default: + raise GraphDeadEnd() + log.info( + f"Ran into a dead end on non-default door {exit_door.name} on node {self._current_node.name} - fallback to default door" + ) + exit_door = await NodeDoor.objects.filter( + node=self._current_node, + door_type=NodeDoor.DoorType.OUTPUT, + is_default=True, + ).afirst() async def cleanup_sc_procedure(self) -> StreamInstruction: log.debug("Run cleanup procedure on graph") @@ -723,7 +732,7 @@

Source code for story_graph.engine

 
             # search for next node
             try:
-                await self.get_next_node()
+                self._current_node = await self.get_next_node()
             except GraphDeadEnd:
                 log.info(f"Ran into a dead end on {self.graph} on {self._current_node}")
                 return