-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
51 lines (42 loc) · 1.67 KB
/
main.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from multiprocessing import freeze_support
from AttackDice import AttackDice
from DefenseDice import DefenseDice
def getInput(include_black=True):
red = int(input("How many red dice? (0): ") or 0)
if include_black:
black = int(input("How many black dice? (0): ") or 0)
else:
black = 0
white = int(input("How many white dice? (0): ") or 0)
surge = input("Can the unit convert surges? (yes): ") or "true"
surge = surge.lower() in ['true', '1', 'y', 'yes']
rolls = int(input("How many times do you want to roll? (10000): ") or 10000)
return {
"red": red,
"black": black,
"white": white,
"surge": surge,
"rolls": rolls,
}
def test():
dice = AttackDice()
result = dice.test(3, 0, 0, 1000000, True)
print("On the attack the roll is likely to have %s successes" % result)
if __name__ == '__main__':
import timeit
freeze_support()
#
# mode = input("Attack or Defend? (attack): ").lower() or "attack"
#
# if mode == "defend":
# dice = DefenseDice()
# userInput = getInput(False)
# result = dice.test(userInput["red"], userInput["white"], userInput["rolls"], userInput["surge"])
# else:
# dice = AttackDice()
# userInput = getInput(True)
# result = dice.test(userInput["red"], userInput["black"], userInput["white"], userInput["rolls"], userInput["surge"])
#
# print("On the %s the roll is likely to have %s successes" % (mode, result))
elapsed_time = timeit.timeit("test()", number=1, setup="from __main__ import test")
print("Elapsed time %s" % elapsed_time)