##RPG Attack and Damage Dice Roller Program## import random import math import time #Instructions# print("RPG Dice Roller\nThis Program will roll attack and damage dice for use in a Role Playing\n\tGame such as Dungeons and Dragons of Pathfinders.") print("You will be asked for the number of dice, the number of sides on the dice,\n\tand the appropriate modifiers (modifiers only for Attack).") print ("Please use only whole numbers; no + or - signs or letters as the program will\n\tnot work.") #Reset Variable# reset = "" #Meat of Program# while reset != "n": #Various Attack Variables# totalAtt = 0 diceNumAtt = 1 diceSideAtt = 20 rollAddAtt = int(input("Enter modifier to be added to Attack roll [0 if none]: ")) rollSubAtt = int(input("Enter modifier to be subtracted from Attack roll [0 if none]: ")) #Various Damage Variables# totalDam = 0 diceNumDam = int(input("Enter number of dice for Damage: ")) diceSideDam = int(input("Enter number of sides (for example 12 for a d12): ")) rollAddDam = int(input("Enter modifier to be added to Attack roll [0 if none]: )) rollSubDam = int(input("Enter modifier to be subtracted from Damage roll [0 if none]: ") #Rolling Attack Now# totalAtt = 0 while diceNumAtt > 0: rollAtt = random.randint (1,20) totalAtt += rollAtt diceNumAtt -= 1 #Attack Modifiers# totalAtt += rollAddAtt totalAtt -= rollSubAtt #Attack Results# print("attack Total:") print(totalAtt) #Rolling Damage Now# totalDam = 0 while diceNumDam > 0: rollDam = random.randint (1,diceSideDam) totalDam += rollDam diceNumDam -= 1 #Damage Modifier# totalDam += rollAddDam totalDam -= rollSubDam #Damage Results# print("Damage Total:") print(totalDam) #Reset Function# reset = input("Reset? y/n: ") #Finish# input("Press Enter to Exit.")
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