Skip to content

Commit 8e80047

Browse files
author
pppprivacy
committed
Wrote risk-risiko. The program does not follow the exact rules specified in the comment. I added a selector for the number of dices the player wants to use like in the original game
1 parent 2bca13e commit 8e80047

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/risk-risiko.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,41 @@
2727
# M 3 vs 3 => blue win
2828
# O 2 vs 1 => red win
2929
#
30+
31+
import random
32+
dice_number = 3
33+
34+
def risiko():
35+
try:
36+
n_dices_red = int(input("[RED] : how many dices would you like to use? "))
37+
n_dices_blue = int(input("[BLUE] : how many dices would you like to use? "))
38+
except:
39+
print("Invalid input! make sure to use a number greater then 0!")
40+
return
41+
42+
if (n_dices_red <=0 or n_dices_blue <=0):
43+
print("Number of dices less then zero are not acceptable")
44+
return
45+
46+
47+
red_dices=list(range(n_dices_red))
48+
blue_dices=list(range(n_dices_blue))
49+
50+
throw_dices(red_dices)
51+
throw_dices(blue_dices)
52+
53+
for i in range(min(n_dices_blue,n_dices_red)):
54+
if blue_dices[i] >= red_dices[i]:
55+
print("Blue won battle number ",i+1," [ R(",red_dices[i],") , B(",blue_dices[i],") ]")
56+
else:
57+
print("Red won battle number ",i+1," [ R(",red_dices[i],") , B(",blue_dices[i],") ]")
58+
59+
60+
def throw_dices(dices):
61+
for i in range (len(dices)):
62+
dices.append(random.randint(1,6))
63+
dices.sort(reverse=True)
64+
65+
risiko()
66+
67+

0 commit comments

Comments
 (0)