Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import random
|
3 |
+
import pandas as pd
|
4 |
+
|
5 |
+
# Initialize session state for game variables and characters
|
6 |
+
if 'current_step' not in st.session_state:
|
7 |
+
st.session_state.current_step = 0
|
8 |
+
if 'player_strength' not in st.session_state:
|
9 |
+
st.session_state.player_strength = 10
|
10 |
+
if 'swordsmen_recruited' not in st.session_state:
|
11 |
+
st.session_state.swordsmen_recruited = []
|
12 |
+
|
13 |
+
# Characters data
|
14 |
+
characters = [
|
15 |
+
{"name": "Alden", "strength": 7, "wisdom": 5, "loyalty": 8},
|
16 |
+
{"name": "Briar", "strength": 6, "wisdom": 9, "loyalty": 7},
|
17 |
+
{"name": "Cade", "strength": 8, "wisdom": 4, "loyalty": 6},
|
18 |
+
{"name": "Dara", "strength": 5, "wisdom": 8, "loyalty": 9},
|
19 |
+
{"name": "Evan", "strength": 9, "wisdom": 3, "loyalty": 5},
|
20 |
+
]
|
21 |
+
|
22 |
+
# Function to roll dice
|
23 |
+
def roll_dice():
|
24 |
+
emoji_dice = ["β", "β", "β", "β", "β", "β
"]
|
25 |
+
roll = random.randint(1, 6)
|
26 |
+
st.markdown(f"Dice roll: {emoji_dice[roll-1]} ({roll})")
|
27 |
+
return roll
|
28 |
+
|
29 |
+
# Function to progress in the story
|
30 |
+
def next_step():
|
31 |
+
st.session_state.current_step += 1
|
32 |
+
|
33 |
+
# Function to recruit a swordsman
|
34 |
+
def recruit_swordsman(swordsman):
|
35 |
+
if swordsman not in st.session_state.swordsmen_recruited:
|
36 |
+
st.session_state.swordsmen_recruited.append(swordsman)
|
37 |
+
st.success(f"{swordsman['name']} has been recruited!")
|
38 |
+
else:
|
39 |
+
st.info(f"{swordsman['name']} is already part of your team.")
|
40 |
+
|
41 |
+
# Title and story progression
|
42 |
+
st.title("The Six Swordsman")
|
43 |
+
|
44 |
+
if st.session_state.current_step == 0:
|
45 |
+
st.markdown("## Introduction")
|
46 |
+
st.markdown("You are the last of the legendary Six Swordsmen. π‘οΈ Seek out your brethren to reform the brotherhood.")
|
47 |
+
if st.button("Begin your quest"):
|
48 |
+
next_step()
|
49 |
+
|
50 |
+
elif st.session_state.current_step == 1:
|
51 |
+
st.markdown("## Quest")
|
52 |
+
st.markdown("Choose a swordsman to investigate and potentially recruit.")
|
53 |
+
|
54 |
+
for character in characters:
|
55 |
+
if st.button(f"Recruit {character['name']}"):
|
56 |
+
recruit_swordsman(character)
|
57 |
+
st.session_state.player_strength += roll_dice() # Gain strength
|
58 |
+
next_step()
|
59 |
+
|
60 |
+
# Display recruited swordsmen and player stats
|
61 |
+
st.sidebar.markdown("### π‘οΈ Player Stats")
|
62 |
+
st.sidebar.markdown(f"- Strength: {st.session_state.player_strength}")
|
63 |
+
st.sidebar.markdown(f"- Swordsmen Recruited: {len(st.session_state.swordsmen_recruited)}/5")
|
64 |
+
|
65 |
+
# Display character stats in an expander
|
66 |
+
with st.expander("View Characters Stats"):
|
67 |
+
df = pd.DataFrame(characters)
|
68 |
+
st.dataframe(df)
|
69 |
+
|
70 |
+
# Future steps can include more complex decision trees, battles with dice rolls, and dynamic story elements based on player choices and character stats.
|