awacke1 commited on
Commit
fd036fa
·
1 Parent(s): 203dc14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -24
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import random
2
 
3
  class DNDCharacter:
@@ -30,31 +31,41 @@ class DNDCharacter:
30
  self.stats[stat] = random.randint(1, 20)
31
 
32
  def show_stats(self):
33
- print("Strength: ", self.stats["Strength"])
34
- print("Dexterity: ", self.stats["Dexterity"])
35
- print("Wisdom: ", self.stats["Wisdom"])
36
- print("Charisma: ", self.stats["Charisma"])
37
- print("Constitution: ", self.stats["Constitution"])
38
- print("Intelligence: ", self.stats["Intelligence"])
39
 
40
  def show_character_sheet(self):
41
- print("Name: ", self.name)
42
- print("Class: ", self.char_class)
43
- print("Level: ", self.level)
44
- print("Race: ", self.race)
45
- print("Background: ", self.background)
46
- print("Alignment: ", self.alignment)
47
  self.show_stats()
48
- print("Hit Points: ", self.hit_points)
49
- print("Armor Class: ", self.armor_class)
50
- print("Initiative: ", self.initiative)
51
- print("Speed: ", self.speed)
52
- print("Proficiencies: ", self.proficiencies)
53
- print("Equipment: ", self.equipment)
54
- print("Features and Traits: ", self.features_and_traits)
55
- print("Spells: ", self.spells)
56
 
57
- # Example usage
58
- character = DNDCharacter("John", "Fighter", 1, "Human", "Soldier", "Lawful Good")
59
- character.roll_stats()
60
- character.show_character_sheet()
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
  import random
3
 
4
  class DNDCharacter:
 
31
  self.stats[stat] = random.randint(1, 20)
32
 
33
  def show_stats(self):
34
+ st.write("Strength: ", self.stats["Strength"])
35
+ st.write("Dexterity: ", self.stats["Dexterity"])
36
+ st.write("Wisdom: ", self.stats["Wisdom"])
37
+ st.write("Charisma: ", self.stats["Charisma"])
38
+ st.write("Constitution: ", self.stats["Constitution"])
39
+ st.write("Intelligence: ", self.stats["Intelligence"])
40
 
41
  def show_character_sheet(self):
42
+ st.write("Name: ", self.name)
43
+ st.write("Class: ", self.char_class)
44
+ st.write("Level: ", self.level)
45
+ st.write("Race: ", self.race)
46
+ st.write("Background: ", self.background)
47
+ st.write("Alignment: ", self.alignment)
48
  self.show_stats()
49
+ st.write("Hit Points: ", self.hit_points)
50
+ st.write("Armor Class: ", self.armor_class)
51
+ st.write("Initiative: ", self.initiative)
52
+ st.write("Speed: ", self.speed)
53
+ st.write("Proficiencies: ", self.proficiencies)
54
+ st.write("Equipment: ", self.equipment)
55
+ st.write("Features and Traits: ", self.features_and_traits)
56
+ st.write("Spells: ", self.spells)
57
 
58
+ # Streamlit app
59
+ st.title("D&D Character Sheet")
60
+
61
+ name = st.text_input("Name")
62
+ char_class = st.text_input("Class")
63
+ level = st.number_input("Level", min_value=1, max_value=20, value=1)
64
+ race = st.text_input("Race")
65
+ background = st.text_input("Background")
66
+ alignment = st.text_input("Alignment")
67
+
68
+ if st.button("Roll Stats"):
69
+ character = DNDCharacter(name, char_class, level, race, background, alignment)
70
+ character.roll_stats()
71
+ character.show_character_sheet()