-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjeu_devinette_1.7.py
203 lines (132 loc) · 4.49 KB
/
jeu_devinette_1.7.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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/usr/bin/env python
from random import randint
import time
from threading import Thread
def prRed(skk): print("\033[91m {}\033[00m" .format(skk))
def say_hi():
print("\n\n***'dévinette 1.6'***\n")
fail = 0
player_name = ''
while player_name == (''):
ask = "Ton nom?\n$ "
player_name = input(ask)
if player_name == (''):
if fail == 0:
print("Tu n'a pas dit ton nom......")
elif fail == 1:
print("Tu te prend pour un/une trés malin!")
elif fail == 2:
print("Désolé tu m'a l'aire pas assez motivé!")
return ''
fail = fail +1
return player_name
def guess(player_name, life):
run_count = False
game_var = randint(1, 100)
while True:
if run_count == False:
create_thread()
t1 = Thread(target=countdown)
t1.start()
if secs == 0:
print('\n\nTemps fini! Tu a perdu une vie!\n')
life -=1
print("Il te reste",life , "vies\n")
return False
if secs != 0:
try:
p_var_int = int(input("$"))
except ValueError:
print("\nC'est ne pas une chiffre!\n")
run_count = True
continue
if p_var_int == game_var:
print('\nGaaagnééé!!!\n')
run_count = True
return True
if p_var_int > (100) and secs != 0:
print("\nc'est ou t'est allé a l'école, " + player_name + ' ?')
print("Tu a encore ", secs, " secondes!")
run_count = True
continue
if p_var_int < game_var and secs != 0:
print("\nC'est plus grand!")
print("Tu a encore ", secs, " secondes!")
run_count = True
continue
if p_var_int > game_var and secs != 0:
print("\nC'est plus petite!")
print("Tu a encore ", secs, " secondes!")
run_count = True
def game(player_name):
global secs
level = 1
life = 3
wait_before_game()
while life > 0:
match level:
case 1:
secs = 30
case 2:
secs = 25
case 3:
secs = 15
case 4:
secs = 10
case 5:
secs = 5
case 6:
secs = 3
case 7:
secs = 3
print("\n" + player_name + ',\ndévinne la chiffre entre 0 et 100!')
print("Tu a", secs, "secondes et", life, "vies")
print("Level:", level)
input("\n*pour commencer appui sur la touche 'entrée'*\n")
print("La partie commence dans!")
secs_play()
win = guess(player_name, life)
if win == True:
level += 1
if win == False:
life -= 1
match level:
case 8:
print("Tu battu le Jeu!!!!!\r")
time.sleep(2)
print("winwinwinwinwinwinwinwinwinwin")
if life > 0:
oui_or_no = input("Est-ce que tu veut continuer?\n\ntappe o pour Oui ou n pour Non\n\n")
if oui_or_no == ('n'):
print('\nau révoir,', (player_name), '!\n\n')
return
print("\nPeeeeeeeerdu! Miau miau miau.......")
time.sleep(5)
def countdown():
global secs
while secs > 0:
#print(secs, end="\r")
time.sleep(1)
secs -= 1
def create_thread():
return Thread(target=countdown)
def secs_play():
secs_play = 5
while secs_play > 1:
time.sleep(1)
secs_play -= 1
print(secs_play, end=("\r "))
if secs_play == 1:
prRed("Dévine!!!\n")
def wait_before_game():
secs_wait = 1
while secs_wait > 0:
print(" ", end=" \r")
time.sleep(0.5)
print("*", end=" \r")
time.sleep(0.5)
print(" ", end="\r")
secs_wait -= 1
player_name = say_hi()
if player_name:
game(player_name)