Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,45 +1,80 @@
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import random
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
#
|
5 |
def roll_dice():
|
6 |
-
|
7 |
-
dice_emojis = ['β', 'β', 'β', 'β', 'β', 'β
']
|
8 |
-
return dice_emojis[result - 1]
|
9 |
|
10 |
# Function to handle character creation
|
11 |
def create_character():
|
12 |
with st.form("Character Creation"):
|
13 |
name = st.text_input("Character Name")
|
14 |
-
trait = st.selectbox("Select a Trait",
|
15 |
-
desire = st.
|
16 |
submitted = st.form_submit_button("Create Character")
|
17 |
if submitted:
|
18 |
-
|
|
|
19 |
st.success(f"Character {name} created successfully!")
|
20 |
|
21 |
-
# Function to start the quest
|
22 |
def start_quest():
|
23 |
st.markdown("## π The Quest Begins")
|
24 |
-
st.
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
def carousel_encounter():
|
35 |
st.markdown("## π Carousel Encounter")
|
36 |
-
st.
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
# This is where you can add logic for the carousel encounter outcomes.
|
41 |
|
42 |
-
# Function to
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
def climactic_choices():
|
44 |
st.markdown("## βοΈ Climactic Choices")
|
45 |
choice = st.radio("What choice will you make?", ["Embrace the change", "Resist the change"])
|
@@ -51,6 +86,16 @@ def climactic_choices():
|
|
51 |
st.markdown("## π¦ Resolution and Transformation")
|
52 |
st.write("Resisting the change keeps the world as it was, but you wonder what could have been.")
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
# Main app function
|
55 |
def main():
|
56 |
st.title("π The Carousel Paper Cutout World Adventure")
|
@@ -59,7 +104,7 @@ def main():
|
|
59 |
if 'character' not in st.session_state:
|
60 |
st.session_state.character = None
|
61 |
|
62 |
-
# Display the story outline
|
63 |
with st.expander("Story Outline and Rules"):
|
64 |
st.markdown("""
|
65 |
### π Story Outline: The Carousel Paper Cutout World
|
@@ -68,16 +113,14 @@ def main():
|
|
68 |
- **Setting:** A vibrant paper cutout world with a central carousel.
|
69 |
""")
|
70 |
|
71 |
-
# Character creation
|
72 |
if st.session_state.character is None:
|
73 |
create_character()
|
74 |
else:
|
75 |
-
|
76 |
-
|
77 |
-
# Game steps
|
78 |
start_quest()
|
79 |
carousel_encounter()
|
80 |
climactic_choices()
|
81 |
|
82 |
if __name__ == "__main__":
|
83 |
-
main()
|
|
|
1 |
+
# pROMPT eVOLUTION IS IN dISCUSSIONS/cOMMUNITY TO SEE PROMPTS AND HOW IT IS MADE.
|
2 |
+
|
3 |
import streamlit as st
|
4 |
import random
|
5 |
+
import pandas as pd
|
6 |
+
|
7 |
+
# Define possible traits, desires, and challenges
|
8 |
+
traits = ["Brave", "Clever", "Kind", "Curious", "Resourceful", "Timid"]
|
9 |
+
desires = ["Find a lost paper artifact", "Become a real-life figure", "Uncover the deepest secret of the carousel"]
|
10 |
+
challenges = [
|
11 |
+
{"name": "Puzzle of the Lost Scroll", "requirement": "Clever", "effect": "gain_item"},
|
12 |
+
{"name": "The Mysterious Shadow", "requirement": "Brave", "effect": "path_change"},
|
13 |
+
{"name": "The Forgotten Message", "requirement": "Curious", "effect": "reveal_info"}
|
14 |
+
]
|
15 |
+
|
16 |
+
# Define items that can be found or earned
|
17 |
+
items = ["Golden Scissors", "Enchanted Glue", "Mystical Parchment"]
|
18 |
|
19 |
+
# Helper function to roll dice
|
20 |
def roll_dice():
|
21 |
+
return random.choice(['β', 'β', 'β', 'β', 'β', 'β
'])
|
|
|
|
|
22 |
|
23 |
# Function to handle character creation
|
24 |
def create_character():
|
25 |
with st.form("Character Creation"):
|
26 |
name = st.text_input("Character Name")
|
27 |
+
trait = st.selectbox("Select a Trait", traits)
|
28 |
+
desire = st.selectbox("What is your character's desire?", desires)
|
29 |
submitted = st.form_submit_button("Create Character")
|
30 |
if submitted:
|
31 |
+
character = {'name': name, 'trait': trait, 'desire': desire, 'items': []}
|
32 |
+
st.session_state.character = character
|
33 |
st.success(f"Character {name} created successfully!")
|
34 |
|
35 |
+
# Function to start the quest with dynamic challenges
|
36 |
def start_quest():
|
37 |
st.markdown("## π The Quest Begins")
|
38 |
+
if st.button("Encounter a Challenge"):
|
39 |
+
challenge = random.choice(challenges)
|
40 |
+
st.write(f"You've encountered: {challenge['name']}.")
|
41 |
+
handle_challenge(challenge)
|
42 |
+
|
43 |
+
# Function to handle challenges
|
44 |
+
def handle_challenge(challenge):
|
45 |
+
if challenge['requirement'] == st.session_state.character['trait']:
|
46 |
+
if challenge['effect'] == "gain_item":
|
47 |
+
item = random.choice(items)
|
48 |
+
st.session_state.character['items'].append(item)
|
49 |
+
st.write(f"Successfully overcome! You found an item: {item}.")
|
50 |
+
elif challenge['effect'] == "path_change":
|
51 |
+
st.write("Successfully overcome! Your path changes, leading to new discoveries.")
|
52 |
+
elif challenge['effect'] == "reveal_info":
|
53 |
+
st.write("Successfully overcome! You uncover important information about the carousel.")
|
54 |
+
else:
|
55 |
+
st.write("Challenge not overcome. Consider trying different approaches or finding items that might help.")
|
56 |
+
|
57 |
+
# Function for carousel encounter with randomized outcomes
|
58 |
def carousel_encounter():
|
59 |
st.markdown("## π Carousel Encounter")
|
60 |
+
if st.button("Ride the Carousel"):
|
61 |
+
st.write("The carousel spins, enveloping you in a whirlwind of colors and sounds.")
|
62 |
+
outcome = roll_dice()
|
63 |
+
handle_carousel_outcome(outcome)
|
|
|
64 |
|
65 |
+
# Function to handle carousel outcomes
|
66 |
+
def handle_carousel_outcome(outcome):
|
67 |
+
# Example outcome handling
|
68 |
+
if outcome in ['β', 'β']:
|
69 |
+
st.write("You receive a vision of a possible future, inspiring you with new determination.")
|
70 |
+
elif outcome in ['β', 'β']:
|
71 |
+
item = random.choice(items)
|
72 |
+
st.session_state.character['items'].append(item)
|
73 |
+
st.write(f"The carousel's magic grants you an item: {item}.")
|
74 |
+
else:
|
75 |
+
st.write("The ride offers you a glimpse of the world's deepest secrets, changing your perspective.")
|
76 |
+
|
77 |
+
# Function to display climactic choices and resolution
|
78 |
def climactic_choices():
|
79 |
st.markdown("## βοΈ Climactic Choices")
|
80 |
choice = st.radio("What choice will you make?", ["Embrace the change", "Resist the change"])
|
|
|
86 |
st.markdown("## π¦ Resolution and Transformation")
|
87 |
st.write("Resisting the change keeps the world as it was, but you wonder what could have been.")
|
88 |
|
89 |
+
# Function to display character and inventory information
|
90 |
+
def display_character_info():
|
91 |
+
if 'character' in st.session_state:
|
92 |
+
char = st.session_state.character
|
93 |
+
st.write(f"Character: {char['name']}, Trait: {char['trait']}, Desire: {char['desire']}")
|
94 |
+
if char['items']:
|
95 |
+
st.write("Inventory:", ", ".join(char['items']))
|
96 |
+
else:
|
97 |
+
st.write("Inventory is empty.")
|
98 |
+
|
99 |
# Main app function
|
100 |
def main():
|
101 |
st.title("π The Carousel Paper Cutout World Adventure")
|
|
|
104 |
if 'character' not in st.session_state:
|
105 |
st.session_state.character = None
|
106 |
|
107 |
+
# Display the story outline and rules using Streamlit markdown
|
108 |
with st.expander("Story Outline and Rules"):
|
109 |
st.markdown("""
|
110 |
### π Story Outline: The Carousel Paper Cutout World
|
|
|
113 |
- **Setting:** A vibrant paper cutout world with a central carousel.
|
114 |
""")
|
115 |
|
116 |
+
# Character creation and game progression
|
117 |
if st.session_state.character is None:
|
118 |
create_character()
|
119 |
else:
|
120 |
+
display_character_info()
|
|
|
|
|
121 |
start_quest()
|
122 |
carousel_encounter()
|
123 |
climactic_choices()
|
124 |
|
125 |
if __name__ == "__main__":
|
126 |
+
main()
|