Spaces:
Runtime error
Runtime error
import streamlit as st | |
import random | |
# Define a function to roll dice and return a random emoji based on the result | |
def roll_dice(): | |
result = random.randint(1, 6) | |
dice_emojis = ['β', 'β', 'β', 'β', 'β', 'β '] | |
return dice_emojis[result - 1] | |
# Function to handle character creation | |
def create_character(): | |
with st.form("Character Creation"): | |
name = st.text_input("Character Name") | |
trait = st.selectbox("Select a Trait", ["Brave", "Clever", "Kind"]) | |
desire = st.text_input("What is your character's desire?") | |
submitted = st.form_submit_button("Create Character") | |
if submitted: | |
st.session_state.character = {'name': name, 'trait': trait, 'desire': desire} | |
st.success(f"Character {name} created successfully!") | |
# Function to start the quest | |
def start_quest(): | |
st.markdown("## π The Quest Begins") | |
st.write("You embark on your journey to find the carousel. Along the way, you encounter various challenges.") | |
challenge = st.button("Face a Challenge") | |
if challenge: | |
st.write(f"You faced a challenge and your path changes. Roll a dice to see the outcome.") | |
dice_result = roll_dice() | |
st.write(f"Dice Roll Result: {dice_result}") | |
# Update the path based on the dice roll if needed | |
# This is where you can add logic to alter the player's path or story based on the dice roll. | |
# Function to encounter the carousel | |
def carousel_encounter(): | |
st.markdown("## π Carousel Encounter") | |
st.write("You've found the carousel! It's time to experience its magic.") | |
ride = st.button("Ride the Carousel") | |
if ride: | |
st.write("The carousel starts spinning and you're engulfed in a whirlwind of colors and sounds.") | |
# This is where you can add logic for the carousel encounter outcomes. | |
# Function to display the climactic choices and resolution | |
def climactic_choices(): | |
st.markdown("## βοΈ Climactic Choices") | |
choice = st.radio("What choice will you make?", ["Embrace the change", "Resist the change"]) | |
if st.button("Make Choice"): | |
if choice == "Embrace the change": | |
st.markdown("## π¦ Resolution and Transformation") | |
st.write("Your choice leads to a beautiful transformation of the world and yourself.") | |
else: | |
st.markdown("## π¦ Resolution and Transformation") | |
st.write("Resisting the change keeps the world as it was, but you wonder what could have been.") | |
# Main app function | |
def main(): | |
st.title("π The Carousel Paper Cutout World Adventure") | |
# Initialize session state variables if not already present | |
if 'character' not in st.session_state: | |
st.session_state.character = None | |
# Display the story outline | |
with st.expander("Story Outline and Rules"): | |
st.markdown(""" | |
### π Story Outline: The Carousel Paper Cutout World | |
- **Objective:** To create a captivating graphic novel set in a magical paper cutout world. | |
- **Theme:** Cycles, changes, and the impact of choices. | |
- **Setting:** A vibrant paper cutout world with a central carousel. | |
""") | |
# Character creation step | |
if st.session_state.character is None: | |
create_character() | |
else: | |
st.write(f"Welcome, {st.session_state.character['name']}!") | |
# Game steps | |
start_quest() | |
carousel_encounter() | |
climactic_choices() | |
if __name__ == "__main__": | |
main() |