import streamlit as st import random import pandas as pd # Initialize session state for game variables and characters if 'current_step' not in st.session_state: st.session_state.current_step = 0 if 'player_strength' not in st.session_state: st.session_state.player_strength = 10 if 'swordsmen_recruited' not in st.session_state: st.session_state.swordsmen_recruited = [] # Characters data characters = [ {"name": "Alden", "strength": 7, "wisdom": 5, "loyalty": 8}, {"name": "Briar", "strength": 6, "wisdom": 9, "loyalty": 7}, {"name": "Cade", "strength": 8, "wisdom": 4, "loyalty": 6}, {"name": "Dara", "strength": 5, "wisdom": 8, "loyalty": 9}, {"name": "Evan", "strength": 9, "wisdom": 3, "loyalty": 5}, ] # Function to roll dice def roll_dice(): emoji_dice = ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"] roll = random.randint(1, 6) st.markdown(f"Dice roll: {emoji_dice[roll-1]} ({roll})") return roll # Function to progress in the story def next_step(): st.session_state.current_step += 1 # Function to recruit a swordsman def recruit_swordsman(swordsman): if swordsman not in st.session_state.swordsmen_recruited: st.session_state.swordsmen_recruited.append(swordsman) st.success(f"{swordsman['name']} has been recruited!") else: st.info(f"{swordsman['name']} is already part of your team.") # Title and story progression st.title("The Six Swordsman") if st.session_state.current_step == 0: st.markdown("## Introduction") st.markdown("You are the last of the legendary Six Swordsmen. 🗡️ Seek out your brethren to reform the brotherhood.") if st.button("Begin your quest"): next_step() elif st.session_state.current_step == 1: st.markdown("## Quest") st.markdown("Choose a swordsman to investigate and potentially recruit.") for character in characters: if st.button(f"Recruit {character['name']}"): recruit_swordsman(character) st.session_state.player_strength += roll_dice() # Gain strength next_step() # Display recruited swordsmen and player stats st.sidebar.markdown("### 🛡️ Player Stats") st.sidebar.markdown(f"- Strength: {st.session_state.player_strength}") st.sidebar.markdown(f"- Swordsmen Recruited: {len(st.session_state.swordsmen_recruited)}/5") # Display character stats in an expander with st.expander("View Characters Stats"): df = pd.DataFrame(characters) st.dataframe(df) # Future steps can include more complex decision trees, battles with dice rolls, and dynamic story elements based on player choices and character stats.