awacke1 commited on
Commit
beed96a
Β·
verified Β·
1 Parent(s): 9089aac

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -0
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")