Skip to content

Commit 32b78c6

Browse files
authored
Merge pull request larymak#162 from calinIul/calinIul-patch-1
Create dice_game_"barbut"
2 parents c386c30 + 096e3cd commit 32b78c6

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

dice_game_"barbut"

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Barbut"""
2+
from random import randint
3+
4+
5+
def barbut():
6+
while True:
7+
score_pairs = [17, 16, 15, 14, 13, 12] # values for pair-outcomes
8+
user = [randint(1,6), randint(1, 6)]
9+
bot = [randint(1, 6), randint(1, 6)]
10+
scor_user = 0
11+
scor_bot = 0
12+
13+
print(f"Your dice: {user[0]}, {user[1]} | Bot's dice: {bot[0]}, {bot[1]}. ")
14+
15+
if user[0] == user[1]:
16+
scor_user = score_pairs[user[0] - 1]
17+
else:
18+
scor_user = user[0] + user[1]
19+
if bot[0] == bot[1]:
20+
scor_bot = score_pairs[bot[0] - 1]
21+
else:
22+
scor_bot = bot[0] + bot[1]
23+
24+
if scor_user > scor_bot:
25+
print("+5$")
26+
break
27+
elif scor_user == scor_bot:
28+
print("Play on")
29+
continue # If result is draw, play again
30+
else:
31+
print("-5$")
32+
break
33+
34+
barbut()

0 commit comments

Comments
 (0)