-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrisk_dice_roll.py
39 lines (29 loc) · 1.25 KB
/
risk_dice_roll.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
import random
defense_die = input("How many defense dice do you want to roll?")
offense_die = input("How many offense dice do you want to roll?")
defense_rolls = []
offense_rolls = []
for die in range(int(defense_die)):
defense_roll = random.randint(1, 6)
defense_rolls.append(defense_roll)
for die in range(int(offense_die)):
offense_roll = random.randint(1, 6)
offense_rolls.append(offense_roll)
sorted_defense = sorted(defense_rolls, reverse=True)
sorted_offense = sorted(offense_rolls, reverse=True)
print(f"Defense Rolls: {sorted_defense}")
print(f"Offense Rolls: {sorted_offense}")
if len(sorted_defense) == 2:
if sorted_defense[0] >= sorted_offense[0] and sorted_defense[-1] >= sorted_offense[1]:
print("Defense won both rolls")
elif sorted_defense[0] >= sorted_offense[0] and sorted_defense[-1] < sorted_offense[1]:
print("Defense won 1 and attack won 1")
#elif sorted_defense[0] < sorted_offense[0] and sorted_defense[1] < sorted_offense[1]:
# print("Offense won both rolls")
else:
print("Offense won both rolls")
else:
if sorted_defense[0] >= sorted_offense[0]:
print("Defense won the roll.")
else:
print("Offense won the roll")