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

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -0
app.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+
3
+ class DNDCharacter:
4
+ def __init__(self, name, char_class, level, race, background, alignment):
5
+ self.name = name
6
+ self.char_class = char_class
7
+ self.level = level
8
+ self.race = race
9
+ self.background = background
10
+ self.alignment = alignment
11
+ self.stats = {
12
+ "Strength": 0,
13
+ "Dexterity": 0,
14
+ "Wisdom": 0,
15
+ "Charisma": 0,
16
+ "Constitution": 0,
17
+ "Intelligence": 0
18
+ }
19
+ self.hit_points = 0
20
+ self.armor_class = 0
21
+ self.initiative = 0
22
+ self.speed = 0
23
+ self.proficiencies = []
24
+ self.equipment = []
25
+ self.features_and_traits = []
26
+ self.spells = []
27
+
28
+ def roll_stats(self):
29
+ for stat in self.stats:
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()