Exemplo n.º 1
0
def encode_story(story: Story) -> str:
    story_dict: Dict[str, Any] = {}

    story_dict['beginning'] = story.beginning().__hash__()
    story_dict['endings'] = [n.__hash__() for n in story._endings]

    nodes = {}
    for node in story._nodes:
        nodes[node.__hash__()] = _encode_node(node)

    story_dict['nodes'] = nodes

    return json.dumps(story_dict)