CYOAMadSweeney / app.py
awacke1's picture
Create app.py
beed96a verified
raw
history blame
2.11 kB
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")