Omnibus commited on
Commit
cc692b7
1 Parent(s): 9480c8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -4
app.py CHANGED
@@ -240,18 +240,44 @@ def get_high_score():
240
  try:
241
  r = requests.get(f'{save_data}game_data.json')
242
  lod = json.loads(r.text)
243
- high_score=[]
 
 
244
  high_score.append("<h3><u>High Score</u></h3><br>")
245
- #lod.sort()
246
  for ea in lod:
247
  try:
248
  print (ea)
249
  print (ea['game_name'])
250
  print (ea['score'])
251
  if ea['score'] != "":
252
- high_score.append(f"{ea['score']}<br>{ea['game_name']}<br><br>")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  #high_score.sort()
254
- except Exception:
 
255
  pass
256
  return high_score
257
 
 
240
  try:
241
  r = requests.get(f'{save_data}game_data.json')
242
  lod = json.loads(r.text)
243
+ high_score=[0,0,0]
244
+ sort_score=[0,0,0]
245
+ print(sort_score)
246
  high_score.append("<h3><u>High Score</u></h3><br>")
 
247
  for ea in lod:
248
  try:
249
  print (ea)
250
  print (ea['game_name'])
251
  print (ea['score'])
252
  if ea['score'] != "":
253
+ if ea['score'] >= sort_score[0]:
254
+ sort_score[2]=sort_score[1]
255
+ high_score[2]=high_score[1]
256
+ sort_score[1]=sort_score[0]
257
+ high_score[1]=high_score[0]
258
+ sort_score[0]=ea['score']
259
+ high_score[0]=(f"{ea['score']}<br>{ea['game_name']}<br><br>")
260
+ print(sort_score)
261
+ print(high_score)
262
+ pass
263
+ elif ea['score'] >= sort_score[1]:
264
+ sort_score[2]=sort_score[1]
265
+ high_score[2]=high_score[1]
266
+ sort_score[1]=ea['score']
267
+ high_score[1]=(f"{ea['score']}<br>{ea['game_name']}<br><br>")
268
+ print(sort_score)
269
+ print(high_score)
270
+ pass
271
+ elif ea['score'] >= sort_score[2]:
272
+ sort_score[2]=ea['score']
273
+ high_score[2]=(f"{ea['score']}<br>{ea['game_name']}<br><br>")
274
+ print(sort_score)
275
+ print(high_score)
276
+ pass
277
+
278
  #high_score.sort()
279
+ except Exception as e:
280
+ print(e)
281
  pass
282
  return high_score
283