Spaces:
Runtime error
Runtime error
File size: 2,462 Bytes
fd036fa 203dc14 fd036fa 203dc14 fd036fa 203dc14 fd036fa 203dc14 fd036fa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
import streamlit as st
import random
class DNDCharacter:
def __init__(self, name, char_class, level, race, background, alignment):
self.name = name
self.char_class = char_class
self.level = level
self.race = race
self.background = background
self.alignment = alignment
self.stats = {
"Strength": 0,
"Dexterity": 0,
"Wisdom": 0,
"Charisma": 0,
"Constitution": 0,
"Intelligence": 0
}
self.hit_points = 0
self.armor_class = 0
self.initiative = 0
self.speed = 0
self.proficiencies = []
self.equipment = []
self.features_and_traits = []
self.spells = []
def roll_stats(self):
for stat in self.stats:
self.stats[stat] = random.randint(1, 20)
def show_stats(self):
st.write("Strength: ", self.stats["Strength"])
st.write("Dexterity: ", self.stats["Dexterity"])
st.write("Wisdom: ", self.stats["Wisdom"])
st.write("Charisma: ", self.stats["Charisma"])
st.write("Constitution: ", self.stats["Constitution"])
st.write("Intelligence: ", self.stats["Intelligence"])
def show_character_sheet(self):
st.write("Name: ", self.name)
st.write("Class: ", self.char_class)
st.write("Level: ", self.level)
st.write("Race: ", self.race)
st.write("Background: ", self.background)
st.write("Alignment: ", self.alignment)
self.show_stats()
st.write("Hit Points: ", self.hit_points)
st.write("Armor Class: ", self.armor_class)
st.write("Initiative: ", self.initiative)
st.write("Speed: ", self.speed)
st.write("Proficiencies: ", self.proficiencies)
st.write("Equipment: ", self.equipment)
st.write("Features and Traits: ", self.features_and_traits)
st.write("Spells: ", self.spells)
# Streamlit app
st.title("D&D Character Sheet")
name = st.text_input("Name")
char_class = st.text_input("Class")
level = st.number_input("Level", min_value=1, max_value=20, value=1)
race = st.text_input("Race")
background = st.text_input("Background")
alignment = st.text_input("Alignment")
if st.button("Roll Stats"):
character = DNDCharacter(name, char_class, level, race, background, alignment)
character.roll_stats()
character.show_character_sheet()
|