''' 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) ability_score = str(random.randint(3,18)) ''' strength = 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 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 strength=ability_score #RaceBonuses if Selected_Race == 'Human': strength[:]=[i+1 for i in strength] if Selected_Race == 'Dwarf': strength[:]=[i+2 for i in strength] if Selected_Race == 'Dragonborn': strength[:]=[i+2 for i in strength] if Selected_Race == 'Half-Orc': strength[:]=[i+2 for i in strength] ''' #Modifier Code for key in Ability_Score_Modifiers: if Ability_Score_Modifiers[key] == Ability_Score_Modifiers[strength]: print("True") print("Stat score of {} grants a modifier of {}".format(strength, Ability_Score_Modifiers[strength])) ''' print strength, (' : Strength') ''' #Dexterity Score for x in range (1): dexterity.append(random.randint(3,18)) #RaceBonuses if Selected_Race == 'Elf': dexterity[:]=[i+2 for i in dexterity] if Selected_Race == 'Halfling': dexterity[:]=[i+2 for i in dexterity] if Selected_Race == 'Gnome': dexterity[:]=[i+1 for i in dexterity] if Selected_Race == 'Human': dexterity[:]=[i+1 for i in dexterity] print dexterity, (' : Dexterity') #Wisdom Score for x in range (1): wisdom.append(random.randint(3,18)) #RaceBonuses if Selected_Race == 'Dwarf': wisdom[:]=[i+1 for i in wisdom] if Selected_Race == 'Elf': wisdom[:]=[i+1 for i in wisdom] if Selected_Race == 'Human': wisdom[:]=[i+1 for i in wisdom] print wisdom, (' : Wisdom ') #Intelligence Score for x in range (1): intelligence.append(random.randint(3,18)) #RaceBonuses if Selected_Race == 'Elf': intelligence[:]=[i+1 for i in intelligence] if Selected_Race == 'Gnome': intelligence[:]=[i+2 for i in intelligence] if Selected_Race == 'Tiefling': intelligence[:]=[i+1 for i in intelligence] if Selected_Race == 'Human': intelligence[:]=[i+1 for i in intelligence] print intelligence, (' : Intelligence') #Constitution Score for x in range (1): constitution.append(random.randint(3,18)) #RaceBonuses if Selected_Race == 'Dwarf': constitution[:]=[i+2 for i in constitution] if Selected_Race == 'Halfing': constitution[:]=[i+1 for i in constitution] if Selected_Race == 'Gnome': constitution[:]=[i+1 for i in constitution] if Selected_Race == 'Half-Orc': constitution[:]=[i+1 for i in constitution] if Selected_Race == 'Human': constitution[:]=[i+1 for i in constitution] print constitution, (' : Constitution') #Charisma Score for x in range (1): charisma.append(random.randint(3,18)) #RaceBonuses if Selected_Race == 'Half-Elf': charisma[:]=[i+2 for i in charisma] if Selected_Race == 'Halfling': charisma[:]=[i+1 for i in charisma] if Selected_Race == 'Dragonborn': charisma[:]=[i+1 for i in charisma] if Selected_Race == 'Human': charisma[:]=[i+1 for i in charisma] if Selected_Race == 'Tiefling': charisma[:]=[i+2 for i in charisma] print charisma, (' : Charisma') ''' 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