File size: 2,107 Bytes
beed96a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import streamlit as st

# Story content structured as a list of dictionaries
story_content = [
    {"id": "start",
     "text": "Essie grows fascinated with faeries and leprechauns, following her grandmother's tales. 🧚",
     "choices": [("Continue", "choice_a")]
    },
    {"id": "choice_a",
     "text": "Does Essie leave gifts for the leprechauns or ignore the traditions? 🎁",
     "choices": [("Leave gifts", "choice_b1"), ("Ignore", "end_ignore")]
    },
    {"id": "choice_b1",
     "text": "Essie decides to steal bread and leave it out for the leprechauns. 🍞",
     "choices": [("Continue", "outcome_b1")]
    },
    {"id": "outcome_b1",
     "text": "Her offering attracts Mad Sweeney, marking the beginning of her intertwined fate with the leprechaun. πŸ€",
     "choices": [("Continue", "choice_c")]
    },
    {"id": "choice_c",
     "text": "After returning to London, does Essie continue her life of crime or attempt to live honestly? πŸ”‘",
     "choices": [("Live a life of crime", "outcome_c1"), ("Live honestly", "end_honest")]
    },
    {"id": "outcome_c1",
     "text": "In her old age, Essie is visited by Mad Sweeney, who thanks her for bringing him to the New World. πŸ‘΅",
     "choices": [("Restart", "start")]
    },
    {"id": "end_ignore",
     "text": "Ignoring the traditions, Essie's life takes a different turn, far from the mystical encounters of her youth. πŸšΆβ€β™€οΈ",
     "choices": [("Restart", "start")]
    },
    {"id": "end_honest",
     "text": "Attempting to live honestly, Essie finds peace in a simpler life, though she occasionally misses the thrill of her past. πŸŒ…",
     "choices": [("Restart", "start")]
    }
]

def render_story_point(story_id):
    story_point = next((item for item in story_content if item["id"] == story_id), None)
    if story_point:
        st.write(story_point["text"])
        for choice_text, next_id in story_point["choices"]:
            if st.button(choice_text):
                render_story_point(next_id)
                break

st.title("Choose Your Own Adventure: Essie's Tale")
render_story_point("start")