-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjuego.py
141 lines (116 loc) · 6.31 KB
/
juego.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
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
import random #Importar una función
print(" █████ █████ █████ ████ █████ █████")
print("░░███ ░░███ ░░███ ░░███ ░░███ ░░███ ")
print(" ░███████ ██████ ███████ ███████ ░███ ██████ ░███████ ██████ ████████ ███████ ")
print(" ░███░░███ ░░░░░███ ░░░███░ ░░░███░ ░███ ███░░███ ░███░░███ ░░░░░███ ░░███░░███ ███░░███ ")
print(" ░███ ░███ ███████ ░███ ░███ ░███ ░███████ ░███ ░███ ███████ ░███ ░███ ░███ ░███ ")
print(" ░███ ░███ ███░░███ ░███ ███ ░███ ███ ░███ ░███░░░ ░███ ░███ ███░░███ ░███ ░███ ░███ ░███ ")
print(" ████████ ░░████████ ░░█████ ░░█████ █████░░██████ ████ █████░░████████ ████ █████░░████████")
print("░░░░░░░░ ░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░ ░░░░░ ░░░░░░░░ ░░░░ ░░░░░ ░░░░░░░░ ")
print('')
user_name = input("¿Cuál es tu nombre 👉 ")
print('')
def choose_option():
options = ('piedra', 'papel', 'tijera') #lo pasamos a global a local, porque solo le interesa a la función saber cuales son las opciones
user_option = input(str(user_name) + ' escoje piedra, papel o tijera 👉 ')
user_option = user_option.lower()
if not user_option in options:
print('esa opción no es válida')
return None, None
computer_option = random.choice(options) #uso función Random
print('User option ', user_option)
print('computer_option', computer_option)
return user_option, computer_option
def check_rules(user_option, computer_option, user_win, computer_win):
if user_option == computer_option:
print('¡Empate!')
elif user_option == 'piedra':
if computer_option == 'tijera':
print('piedra gana a tijera')
print('¡user ganó!')
user_win += 1
else:
print('papel gana a piedra')
print('¡computer ganó!')
computer_win += 1
elif user_option == 'papel':
if computer_option == 'piedra':
print('papel gana a piedra')
print('¡user ganó!')
user_win += 1
else:
print('tijera gana a papel')
print('¡computer ganó!')
computer_win += 1
elif user_option == 'tijera':
if computer_option == 'papel':
print('tijera gana a papel')
print('¡user ganó!')
user_win += 1
else:
print('piedra gana a tijera')
print('¡computer ganó!')
computer_win += 1
return user_win, computer_win
def check_winner(user_win, computer_win):
if computer_win == 2:
print('*' * 10)
print('')
print('el ganador es la computadora')
print('')
print('____██████████████')
print('___██▓▓▓▓▓▓▓▓▓ M ▓███')
print('_██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██')
print('_██████░░░░██░░█████')
print('█░░░████░░██░░░░░░░██')
print('█░░░████░░░░██░░░░░██')
print('_████░░░░░░█████████')
print('_██░░░░░░░░░░░░░██')
print('___██░░░░░░░░░██')
print('_____██░░░░░░██')
print('___██▓▓████▓▓▓█')
print('██▓▓▓▓▓▓████▓▓█')
print('▓▓▓▓▓▓███░░███░')
print('_██░░░░░░███████')
print('___██░░░░███████')
print('_____██████████')
print('____██▓▓▓▓▓▓▓▓▓██')
print('')
exit()
if user_win == 2:
print('*' * 10)
print('')
print('¡', user_name, 'haz ganado!')
print('')
print("░░░░░░░░░░░░░░░░░░░░░░░░░")
print("░░░░▄▄▄░░░█▄▄▄█░░░▄▄▄░░░░")
print("░░▄███░░░░█████░░░░███▄░░")
print("▄█████▄░░▄█████▄░░▄█████▄")
print("█████████████████████████")
print("█████████████████████████")
print("█████████████████████████")
print("░▀███████▀█████▀███████▀░")
print("░░░▀███▀░░░███░░░▀███▀░░░")
print("░░░░░░▀░░░░░▀░░░░░▀░░░░░░")
print('')
print('')
exit()
def run_game():
computer_win = 0
user_win = 0
rounds = 1
emoji = ('🤓', '😎', '😭', '🦁', '🎸', '✂️', '👻', '🩰', '🏀')
while True:
print('')
print('*' * 20)
print('ROUND', rounds, random.choice(emoji))
print('*' * 20)
print('')
print('Ganadas Usuario:', user_win)
print('Ganadas computadora:', computer_win)
print('')
user_option, computer_option = choose_option()
user_win, computer_win = check_rules(user_option, computer_option, user_win, computer_win)
rounds += 1
check_winner(user_win, computer_win)
run_game()