-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRockPaperGame.py
More file actions
167 lines (131 loc) · 5.28 KB
/
RockPaperGame.py
File metadata and controls
167 lines (131 loc) · 5.28 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
from time import sleep
from random import choice
user_score = 0
computer_score = 0
choices = ["к", "н", "б"]
jokes = [
"Посмотри в глупь себя",
"Классное имя Изяслав: когда надо - Изя, когда надо - Слава",
"Ночью подошёл к холодильнику – пришлось в очереди стоять",
"У меня такой ИНН, что тебе и не СНИЛС",
"Матрасы полосатые для того, чтобы знать, в каком направлении ложиться",
"Доброе дело надо делать внезапно, чтобы не догнали",
"Что сразу дураков не убивает, то делает их ещё дурнее",
"В жизни главное - не лениться, захотел поспать - поспи",
"Умный в гору не пойдёт - арендует вертолёт",
"Ехал на дачу, поспорил с навигатором - проспорил"
]
def show_score():
print()
sleep(1)
print(">>> Счет игры: ", user_score, ":", computer_score, sep="", end=" ")
if user_score > computer_score:
print("(Пользователь выигрывает)")
elif user_score < computer_score:
print("(Компьютер выигрывает)")
else:
print("(Ничья)")
print()
def show_joke():
joke = choice(jokes)
print(">>> -", joke)
print("******************************")
print("* *")
print("* Камень-Ножницы-Бумага! *")
print("* *")
print("******************************")
print()
max_score = 0
while max_score not in [1, 2, 3, 4, 5]:
max_score = int(input(">>> До скольки очков играем? (1-5): "))
if max_score not in [1, 2, 3, 4, 5]:
print("!!! Вы можете выбрать от 1 до 5!")
print()
sleep(1)
show_score()
while user_score < max_score and computer_score < max_score:
sleep(1)
user_choice = ""
while user_choice not in ["к", "н", "б", "о"]:
user_choice = input(">>> Загадайте фигуру (К)амень, (Н)ожницы, (Б)умага или (О)становите игру: ").lower()
if user_choice not in ["к", "н", "б", "о"]:
print("!!! Введите первую букву своего выбора: \"К\" - камень, \"Н\" - ножницы, \"Б\" - бумага или \"О\" - остановить игру")
print()
sleep(1)
print(">>> Выбор пользователя: ", end="")
if user_choice == "к":
print("Камень")
elif user_choice == "н":
print("Ножницы")
elif user_choice == "б":
print("Бумага")
elif user_choice == "о":
print("Остановить игру")
show_score()
print(">>> Анекдот на прощание: ")
show_joke()
print()
print("Удачи!")
quit()
print(">>> Выбор компьютера: ", end="")
for i in range(3):
sleep(1)
print(".", end=" ")
sleep(1)
computer_choice = choice(choices)
if computer_choice == "к":
print("Камень")
elif computer_choice == "н":
print("Ножницы")
elif computer_choice == "б":
print("Бумага")
print(">>> ", end="")
if user_choice == "к":
if computer_choice == "к":
print("В этот раз ничья")
if computer_choice == "н":
print("Пользователь победил!")
user_score += 1
if computer_choice == "б":
print("Компьютер победил!")
computer_score += 1
print()
print(">>> Утешительный анекдот:")
show_joke()
elif user_choice == "н":
if computer_choice == "к":
print("Компьютер победил!")
computer_score += 1
print()
print(">>> Утешительный анекдот:")
show_joke()
if computer_choice == "н":
print("В этот раз ничья")
if computer_choice == "б":
print("Пользователь победил!")
user_score += 1
elif user_choice == "б":
if computer_choice == "к":
print("Пользователь победил!")
user_score += 1
if computer_choice == "н":
print("Компьютер победил!")
computer_score += 1
print()
print(">>> Утешительный анекдот:")
show_joke()
if computer_choice == "б":
print("В этот раз ничья")
show_score()
print(">>> Игра закончена со счетом ", user_score, ":", computer_score)
if user_score > computer_score:
print(">>> Пользователь выиграл!")
else:
print(">>> Компьютер выиграл!")
sleep(1)
print()
print(">>> Анекдот на прощание: ")
show_joke()
print()
print("Удачи!")
quit()