awacke1 commited on
Commit
db5d9ba
Β·
verified Β·
1 Parent(s): b961cd4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +95 -0
app.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import random
4
+
5
+ # Initialize session state variables if they don't exist
6
+ if 'current_act' not in st.session_state:
7
+ st.session_state.current_act = 'Act 1: Introduction'
8
+ if 'protagonist_name' not in st.session_state:
9
+ st.session_state.protagonist_name = 'Alex'
10
+
11
+ def roll_dice():
12
+ """Simulate rolling a dice and return the result."""
13
+ return random.randint(1, 6)
14
+
15
+ def on_name_change():
16
+ """Update protagonist's name based on user input."""
17
+ st.session_state.protagonist_name = st.session_state.user_name
18
+
19
+ def advance_act():
20
+ """Advance the story to the next act."""
21
+ acts = ['Act 1: Introduction', 'Act 2: Development', 'Act 3: Conclusion']
22
+ current_index = acts.index(st.session_state.current_act)
23
+ if current_index < len(acts) - 1:
24
+ st.session_state.current_act = acts[current_index + 1]
25
+ st.experimental_rerun()
26
+
27
+ st.title('Graphic Novel: Discovery of a Safe Haven or Cure')
28
+
29
+ # Allow the user to input their name for the protagonist
30
+ st.text_input("What's your protagonist's name?", key='user_name', on_change=on_name_change)
31
+
32
+ st.write(f'Current Act: {st.session_state.current_act}')
33
+
34
+ # Display the story based on the current act
35
+ if st.session_state.current_act == 'Act 1: Introduction':
36
+ st.markdown('''
37
+ - **Setting the Scene** 🌍: Our world is on the brink of collapse...
38
+ - **Introducing the Protagonist** πŸ‘€: {}, a young scientist, stumbles upon...
39
+ - **Inciting Incident** ⚑: {} finds an ancient manuscript hinting at...
40
+ '''.format(st.session_state.protagonist_name, st.session_state.protagonist_name))
41
+
42
+ elif st.session_state.current_act == 'Act 2: Development':
43
+ st.markdown('''
44
+ - **Rising Action** πŸ“ˆ: As {} deciphers the manuscript...
45
+ - **Key Dramatic Situations**:
46
+ 1. **The Quest** πŸ—ΊοΈ: {} sets out to...
47
+ 2. **Rivalry of Superior and Inferior** 🀼: But {} is not alone in this quest...
48
+ 3. **Crucial Choice** ✨: Faced with a dire choice, {} must decide...
49
+ '''.format(st.session_state.protagonist_name, st.session_state.protagonist_name, st.session_state.protagonist_name, st.session_state.protagonist_name))
50
+
51
+ elif st.session_state.current_act == 'Act 3: Conclusion':
52
+ st.markdown('''
53
+ - **Climax** πŸ”₯: In the heart of the forbidden zone...
54
+ - **Resolution** 🏁: With the cure in hand, {}...
55
+ - **Denouement** πŸŒ…: The world slowly heals, and {}...
56
+ '''.format(st.session_state.protagonist_name, st.session_state.protagonist_name))
57
+
58
+ # Implement dice roll for decisions
59
+ st.write('Roll a dice to decide your fate:')
60
+ dice_result = st.button('Roll Dice')
61
+ if dice_result:
62
+ roll = roll_dice()
63
+ st.write(f'You rolled: {roll} 🎲')
64
+
65
+ # Advance to the next act
66
+ if st.button('Advance to Next Act'):
67
+ advance_act()
68
+
69
+ # Implement file uploader for character images
70
+ st.subheader('Upload Character Image')
71
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png"])
72
+ if uploaded_file is not None:
73
+ st.image(uploaded_file, caption='Your Character')
74
+
75
+ # Implement camera input for user engagement
76
+ st.subheader('Capture Your Adventure Look')
77
+ picture = st.camera_input("Take a picture")
78
+ if picture:
79
+ st.image(picture, caption='Your Adventure Look')
80
+
81
+ # Example inline data table for entity stats
82
+ st.subheader('Character Stats')
83
+ character_stats = pd.DataFrame({
84
+ 'Stat': ['Strength', 'Intelligence', 'Charisma'],
85
+ 'Value': [roll_dice(), roll_dice(), roll_dice()]
86
+ })
87
+ st.write(character_stats)
88
+
89
+ # Add expander for game rules or additional info
90
+ with st.expander("Game Rules"):
91
+ st.markdown('''
92
+ - **Rule 1**: Your fate is determined by the roll of a dice.
93
+ - **Rule 2**: Choices will guide the story's direction.
94
+ - **Rule 3**: Every act advances the plot and challenges.
95
+ ''')