-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrussian_roulette.py
64 lines (59 loc) · 1.64 KB
/
russian_roulette.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
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python3
# Russian roulette with seven-shot revolver.
from random import randint
def guess():
# Check user input and return correct answer
while True:
number = input("Press '1' ,'2' or 'e(xit)' and then press 'Enter'")
if number == '1' or number == '2':
return number
elif number == 'e':
exit()
else:
print("Incoret input")
def roulette():
# Spin chamber and pull trigger.
# True for live, and false for dead
if (randint(0,100)) > 30: # Condition to successful validation pull trigger.
return True
else:
return False
def game():
# main loop of game
pressure_counter = 0
while pressure_counter < 7:
chose = guess()
if chose == '1':
life = roulette()
# Check life
if life:
print("-CLICK-")
pressure_counter += 1
else:
print("BANG! YOU ARE DEAD!!!")
return
else:
print("Ha ha ha. Chicken!!!")
return
if pressure_counter == 7:
print("YOU WIN!!!")
def main():
game_status = True
while game_status:
print("""
Russian roulette. \n
This a game of >>>>>>> RUSSIAN ROULETTE. \n
DO NOT TRY THIS IN REALITY!!!\n
Here is a seven-shot revolver.
Type '1' to spin chamber and pull trigger.
Type '2' to give up.
Go... """)
game()
print(""" \n\n\n
Do you want play again?
Type '1' or '2' to yes and 'e' to exit""")
game_status = guess()
print(" \n\n\n")
print("Bye, bye. Thank you to playing.")
if __name__ == "__main__":
main()