Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- from numpy import random
- import sys
- def dice(amount = 1, sides = 20):
- if amount >= 1 and amount <= 10 and type(amount) is int:
- if sides >= 2 and sides <= 100 and type(sides) is int:
- thinking()
- print(f"You rolled {amount} d{sides} and got...")
- thinking()
- if amount > 1:
- for amount in range(amount - 1):
- print(f"...a {random.randint(sides) + 1}...")
- thinking()
- print(f"...and a {random.randint(sides) + 1}.")
- else:
- print(f"...a {random.randint(sides) + 1}.")
- elif sides == "inf" or sides == "infinity" or sides == "∞" or sides == "inifnite":
- thinking(6)
- print("Well done, you have jump-started the destruction of the universe. That's terrific.")
- else:
- user_error()
- prog_end()
- def thinking(zzz = 3):
- for z in range(zzz):
- print(".", end=" ", flush=True)
- time.sleep(0.175)
- print("")
- print("")
- def prog_end():
- thinking(6)
- input("Press any key to exit")
- print("Bye, nerd.")
- time.sleep(1)
- sys.exit()
- def user_error():
- thinking(6)
- print("...you can't use that to roll dice. Are you okay?")
- prog_end()
- # Uncomment the next two lines if calling the script externally
- # (need to write code to adapt to this automatically)
- #input1 = sys.argv[1]
- #input2 = sys.argv[2]
- # Uncomment the next two lines to ask for user input in the Python shell (rather than accept external input)
- input1 = input("How many dice? (1-10)")
- input2 = input("How many sides? (2-100)")
- try:
- input1 = int(input1)
- except:
- user_error()
- thinking()
- try:
- if input2 == "inf" or input2 == "infinity" or input2 == "∞" or input2 == "inifnite":
- thinking(6)
- print("Well done, you have jump-started the destruction of the universe. That's terrific.")
- prog_end()
- input2 = int(input2)
- except:
- user_error()
- dice(input1, input2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement