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