Spaces:
Runtime error
Runtime error
Upload utils.py
Browse files
utils.py
CHANGED
@@ -187,7 +187,8 @@ def add_new_pokemon(new_pokemon):
|
|
187 |
return metadata
|
188 |
|
189 |
def is_lucky(streak):
|
190 |
-
|
|
|
191 |
p = (-0.0274 * streak + 30) / 100
|
192 |
|
193 |
# Generate a random number from the Bernoulli distribution
|
@@ -204,7 +205,10 @@ def lucky_draw():
|
|
204 |
"""
|
205 |
metadata = read_metadata()
|
206 |
gifts = ['energy', 'pokemon', 'money', 'minifigure']
|
207 |
-
|
|
|
|
|
|
|
208 |
|
209 |
gift = gifts[random_number]
|
210 |
if gift == 'money':
|
@@ -241,6 +245,8 @@ def new_streak(intensity):
|
|
241 |
metadata = read_metadata()
|
242 |
metadata["streak"] += 1
|
243 |
streak = metadata["streak"]
|
|
|
|
|
244 |
reward = ""
|
245 |
|
246 |
date1 = datetime.datetime.today()
|
|
|
187 |
return metadata
|
188 |
|
189 |
def is_lucky(streak):
|
190 |
+
if (streak == 2) or (streak == 3):
|
191 |
+
return True
|
192 |
p = (-0.0274 * streak + 30) / 100
|
193 |
|
194 |
# Generate a random number from the Bernoulli distribution
|
|
|
205 |
"""
|
206 |
metadata = read_metadata()
|
207 |
gifts = ['energy', 'pokemon', 'money', 'minifigure']
|
208 |
+
if (metadata["streak"] == 2) or (metadata["streak"] == 3):
|
209 |
+
random_number = 1
|
210 |
+
else:
|
211 |
+
random_number = random.choices([0, 1, 2, 3], weights=[0.3, 0.3, 0.3, 0.1])[0]
|
212 |
|
213 |
gift = gifts[random_number]
|
214 |
if gift == 'money':
|
|
|
245 |
metadata = read_metadata()
|
246 |
metadata["streak"] += 1
|
247 |
streak = metadata["streak"]
|
248 |
+
save_metadata()
|
249 |
+
|
250 |
reward = ""
|
251 |
|
252 |
date1 = datetime.datetime.today()
|