awacke1's picture
Create app.py
203dc14
raw
history blame
2.07 kB
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):
print("Strength: ", self.stats["Strength"])
print("Dexterity: ", self.stats["Dexterity"])
print("Wisdom: ", self.stats["Wisdom"])
print("Charisma: ", self.stats["Charisma"])
print("Constitution: ", self.stats["Constitution"])
print("Intelligence: ", self.stats["Intelligence"])
def show_character_sheet(self):
print("Name: ", self.name)
print("Class: ", self.char_class)
print("Level: ", self.level)
print("Race: ", self.race)
print("Background: ", self.background)
print("Alignment: ", self.alignment)
self.show_stats()
print("Hit Points: ", self.hit_points)
print("Armor Class: ", self.armor_class)
print("Initiative: ", self.initiative)
print("Speed: ", self.speed)
print("Proficiencies: ", self.proficiencies)
print("Equipment: ", self.equipment)
print("Features and Traits: ", self.features_and_traits)
print("Spells: ", self.spells)
# Example usage
character = DNDCharacter("John", "Fighter", 1, "Human", "Soldier", "Lawful Good")
character.roll_stats()
character.show_character_sheet()