''' Fifth Edition D&D Random Character Creator - Python Edition Author: Martin Osburn (Fearless Adventures Incorporated) ''' import random #Global Values Race_Choices = ['Human', 'Half-Elf', 'Elf', 'Dwarf', 'Half-Orc', 'Halfing', 'Tiefling', 'Dragonborn', 'Gnome'] Class_Choices = ['Barbarian', 'Bard', 'Cleric', 'Druid', 'Fighter', 'Monk', 'Paladin', 'Ranger', 'Rogue', 'Sorcerer', 'Warlock', 'Wizard'] Selected_Race = random.choice(Race_Choices) Selected_Class = random.choice(Class_Choices) st_score = str(random.randint(3,18)) dexterity = str(random.randint(3,18)) wisdom = str(random.randint(3,18)) intelligence = str(random.randint(3,18)) constitution = str(random.randint(3,18)) charisma = str(random.randint(3,18)) #skill_score = ['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'] #skill_modifier = ['-5','-4','-4','-3','-3','-2','-2','-1','-1','0','0','+1','+1','+1','+2','+2','+3','+3','+4','+4','+4','+5','+5','+6','+6','+7','+7','+8','+8','+9','+10'] Ability_Score_Modifiers = {'1' : '-5', '2' : '-4', '3' : '-4', '4' : '-3', '5' : '-3', '6' : '-2', '7' : '-2', '8' : '-1', '9' : '-1', '10' : '0', '11' : '0', '12' : '+1', '13' : '+1', '14' : '+2', '15' : '+2', '16' : '+3', '17' : '+3', '18' : '+4', '19' : '+4', '20' : '+5', '21' : '+5', '22' : '+6', '23' : '+6', '24' : '+7', '25' : '+7', '26' : '+8', '27' : '+8', '28' : '+9', '29' : '+9', '30' : '+10'} #Print Prompt to Enter First Name and Last Name #firstname=input('Please Chose a First Name :') #lastname=input('Please Chose a Last Name :') #print(firstname, lastname) #Print Selected Race from List def race_generator(): print (Selected_Race) #Print Select Class from List def class_generator(): print (Selected_Class) #Random Number Generator for Stats (6 values from 1 - 18) def stat_generator(): print('----------Ability Scores----------') #Strength Score print (st_score) #RaceBonuses if Selected_Race == 'Human': st_bonus = str(1) strength = str(int(st_score)+int(st_bonus)) elif Selected_Race == 'Dwarf': st_bonus = str(2) strength = str(int(st_score)+int(st_bonus)) elif Selected_Race == 'Dragonborn': st_bonus = str(2) strength = str(int(st_score)+int(st_bonus)) elif Selected_Race == 'Half-Orc': st_bonus = str(2) strength = str(int(st_score)+int(st_bonus)) else: strength = (st_score) #Modifier Code for key in Ability_Score_Modifiers: if key == strength: print("Strength\nScore of {}\nGrants a modifier of {}".format(strength, Ability_Score_Modifiers[strength])) else: pass print('------------------------------------------') #Dexterity Score #RaceBonuses #Modifier Code for key in Ability_Score_Modifiers: if key == dexterity: print("Dexterity\nScore of {}\nGrants a modifier of {}".format(dexterity, Ability_Score_Modifiers[dexterity])) else: pass print('------------------------------------------') #Wisdom Score #RaceBonuses for key in Ability_Score_Modifiers: if key == wisdom: print("Wisdom\nScore of {}\nGrants a modifier of {}".format(wisdom, Ability_Score_Modifiers[wisdom])) else: pass print('------------------------------------------') #Intelligence Score #RaceBonuses #Modifier Code for key in Ability_Score_Modifiers: if key == intelligence: print("Intelligence\nScore of {}\nGrants a modifier of {}".format(intelligence, Ability_Score_Modifiers[intelligence])) else: pass print('------------------------------------------') #Constitution Score #RaceBonuses #Modifier Code for key in Ability_Score_Modifiers: if key == constitution: print("Constitution\nScore of {}\nGrants a modifier of {}".format(constitution, Ability_Score_Modifiers[constitution])) else: pass print('------------------------------------------') #Charisma Score #RaceBonuses #Modifier Code for key in Ability_Score_Modifiers: if key == charisma: print("Charisma\nScore of {}\nGrants a modifier of {}".format(charisma, Ability_Score_Modifiers[charisma])) else: pass print('------------------------------------------') def main(): race_generator() class_generator() stat_generator() main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question