Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
# Story content structured as a list of dictionaries
|
4 |
+
story_content = [
|
5 |
+
{"id": "start",
|
6 |
+
"text": "Essie grows fascinated with faeries and leprechauns, following her grandmother's tales. π§",
|
7 |
+
"choices": [("Continue", "choice_a")]
|
8 |
+
},
|
9 |
+
{"id": "choice_a",
|
10 |
+
"text": "Does Essie leave gifts for the leprechauns or ignore the traditions? π",
|
11 |
+
"choices": [("Leave gifts", "choice_b1"), ("Ignore", "end_ignore")]
|
12 |
+
},
|
13 |
+
{"id": "choice_b1",
|
14 |
+
"text": "Essie decides to steal bread and leave it out for the leprechauns. π",
|
15 |
+
"choices": [("Continue", "outcome_b1")]
|
16 |
+
},
|
17 |
+
{"id": "outcome_b1",
|
18 |
+
"text": "Her offering attracts Mad Sweeney, marking the beginning of her intertwined fate with the leprechaun. π",
|
19 |
+
"choices": [("Continue", "choice_c")]
|
20 |
+
},
|
21 |
+
{"id": "choice_c",
|
22 |
+
"text": "After returning to London, does Essie continue her life of crime or attempt to live honestly? π",
|
23 |
+
"choices": [("Live a life of crime", "outcome_c1"), ("Live honestly", "end_honest")]
|
24 |
+
},
|
25 |
+
{"id": "outcome_c1",
|
26 |
+
"text": "In her old age, Essie is visited by Mad Sweeney, who thanks her for bringing him to the New World. π΅",
|
27 |
+
"choices": [("Restart", "start")]
|
28 |
+
},
|
29 |
+
{"id": "end_ignore",
|
30 |
+
"text": "Ignoring the traditions, Essie's life takes a different turn, far from the mystical encounters of her youth. πΆββοΈ",
|
31 |
+
"choices": [("Restart", "start")]
|
32 |
+
},
|
33 |
+
{"id": "end_honest",
|
34 |
+
"text": "Attempting to live honestly, Essie finds peace in a simpler life, though she occasionally misses the thrill of her past. π
",
|
35 |
+
"choices": [("Restart", "start")]
|
36 |
+
}
|
37 |
+
]
|
38 |
+
|
39 |
+
def render_story_point(story_id):
|
40 |
+
story_point = next((item for item in story_content if item["id"] == story_id), None)
|
41 |
+
if story_point:
|
42 |
+
st.write(story_point["text"])
|
43 |
+
for choice_text, next_id in story_point["choices"]:
|
44 |
+
if st.button(choice_text):
|
45 |
+
render_story_point(next_id)
|
46 |
+
break
|
47 |
+
|
48 |
+
st.title("Choose Your Own Adventure: Essie's Tale")
|
49 |
+
render_story_point("start")
|