import streamlit as st # Expanded story content with directions story_content = [ {"id": "start", "text": "Essie grows fascinated with faeries and leprechauns, following her grandmother's tales. 🧚", "choices": [("Explore", "choice_a")] }, {"id": "choice_a", "text": "Which direction does Essie explore? 🧭", "choices": [("North", "north_discovery"), ("South", "south_discovery"), ("East", "east_discovery"), ("West", "west_discovery")] }, {"id": "north_discovery", "text": "Essie discovers a hidden glen, alive with faerie lights. 🌌", "choices": [("Perform a ritual", "ritual_outcome"), ("Explore cautiously", "explore_outcome")] }, {"id": "south_discovery", "text": "Essie finds a mystical lake reflecting the moon's glow. 🌕", "choices": [("Perform a ritual", "ritual_outcome"), ("Explore cautiously", "explore_outcome")] }, {"id": "east_discovery", "text": "Essie encounters a grove with a mysterious faerie circle. 🍄", "choices": [("Perform a ritual", "ritual_outcome"), ("Explore cautiously", "explore_outcome")] }, {"id": "west_discovery", "text": "Essie stumbles upon an ancient tree, rumored to be a portal to the Otherworld. 🌳", "choices": [("Perform a ritual", "ritual_outcome"), ("Explore cautiously", "explore_outcome")] }, {"id": "ritual_outcome", "text": "The ritual connects Essie with the faerie realm, leading to a magical encounter. ✨", "choices": [("Use knowledge to preserve tradition", "preserve_tradition"), ("Use gift for personal gain", "personal_gain")] }, {"id": "explore_outcome", "text": "Cautious exploration reveals hidden truths of the mystical world. 🔍", "choices": [("Use knowledge to preserve tradition", "preserve_tradition"), ("Use gift for personal gain", "personal_gain")] }, {"id": "preserve_tradition", "text": "Essie returns home, enriched with stories and traditions to pass down. 📚", "choices": [("Restart", "start")] }, {"id": "personal_gain", "text": "Using her new-found knowledge/gift, Essie seeks to benefit herself, changing her destiny. 💰", "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): st.session_state['current_id'] = next_id # Update the current story ID in session state break st.title("Choose Your Own Adventure: Essie's Journey") # Initialize or update current story ID in session state if 'current_id' not in st.session_state: st.session_state['current_id'] = "start" render_story_point(st.session_state['current_id'])