import streamlit as st import pandas as pd import random # Initialize session state variables if they don't exist if 'current_act' not in st.session_state: st.session_state.current_act = 'Act 1: Introduction' if 'protagonist_name' not in st.session_state: st.session_state.protagonist_name = 'Alex' def roll_dice(): """Simulate rolling a dice and return the result.""" return random.randint(1, 6) def on_name_change(): """Update protagonist's name based on user input.""" st.session_state.protagonist_name = st.session_state.user_name def advance_act(): """Advance the story to the next act.""" acts = ['Act 1: Introduction', 'Act 2: Development', 'Act 3: Conclusion'] current_index = acts.index(st.session_state.current_act) if current_index < len(acts) - 1: st.session_state.current_act = acts[current_index + 1] st.experimental_rerun() st.title('Graphic Novel: Discovery of a Safe Haven or Cure') # Allow the user to input their name for the protagonist st.text_input("What's your protagonist's name?", key='user_name', on_change=on_name_change) st.write(f'Current Act: {st.session_state.current_act}') # Display the story based on the current act if st.session_state.current_act == 'Act 1: Introduction': st.markdown(''' - **Setting the Scene** 🌍: Our world is on the brink of collapse... - **Introducing the Protagonist** πŸ‘€: {}, a young scientist, stumbles upon... - **Inciting Incident** ⚑: {} finds an ancient manuscript hinting at... '''.format(st.session_state.protagonist_name, st.session_state.protagonist_name)) elif st.session_state.current_act == 'Act 2: Development': st.markdown(''' - **Rising Action** πŸ“ˆ: As {} deciphers the manuscript... - **Key Dramatic Situations**: 1. **The Quest** πŸ—ΊοΈ: {} sets out to... 2. **Rivalry of Superior and Inferior** 🀼: But {} is not alone in this quest... 3. **Crucial Choice** ✨: Faced with a dire choice, {} must decide... '''.format(st.session_state.protagonist_name, st.session_state.protagonist_name, st.session_state.protagonist_name, st.session_state.protagonist_name)) elif st.session_state.current_act == 'Act 3: Conclusion': st.markdown(''' - **Climax** πŸ”₯: In the heart of the forbidden zone... - **Resolution** 🏁: With the cure in hand, {}... - **Denouement** πŸŒ…: The world slowly heals, and {}... '''.format(st.session_state.protagonist_name, st.session_state.protagonist_name)) # Implement dice roll for decisions st.write('Roll a dice to decide your fate:') dice_result = st.button('Roll Dice') if dice_result: roll = roll_dice() st.write(f'You rolled: {roll} 🎲') # Advance to the next act if st.button('Advance to Next Act'): advance_act() # Implement file uploader for character images st.subheader('Upload Character Image') uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png"]) if uploaded_file is not None: st.image(uploaded_file, caption='Your Character') # Implement camera input for user engagement st.subheader('Capture Your Adventure Look') picture = st.camera_input("Take a picture") if picture: st.image(picture, caption='Your Adventure Look') # Example inline data table for entity stats st.subheader('Character Stats') character_stats = pd.DataFrame({ 'Stat': ['Strength', 'Intelligence', 'Charisma'], 'Value': [roll_dice(), roll_dice(), roll_dice()] }) st.write(character_stats) # Add expander for game rules or additional info with st.expander("Game Rules"): st.markdown(''' - **Rule 1**: Your fate is determined by the roll of a dice. - **Rule 2**: Choices will guide the story's direction. - **Rule 3**: Every act advances the plot and challenges. ''')