Use same rank for tied scores

This commit is contained in:
gsemaj 2023-12-22 22:14:05 -08:00
parent e0e0b3c5e3
commit f02c960497
No known key found for this signature in database
GPG Key ID: 24B96BAA40497929

View File

@ -73,8 +73,15 @@ def get_score_entries(data, name):
# data.append(((999, 'hehe', 'dong', 1)))
scores="<{}>\n".format(name)
for rank, item in enumerate(data, start=1):
scores+='\t<score>PCUID="{}" Score="{}" Rank="{}" FirstName="{}" LastName="{}"</score>\n'.format(item[0], item[3], rank, item[1], item[2])
rank = 1
last_score = -1
for item in data:
score = item[3]
if score == last_score:
rank -= 1
scores+='\t<score>PCUID="{}" Score="{}" Rank="{}" FirstName="{}" LastName="{}"</score>\n'.format(item[0], score, rank, item[1], item[2])
rank += 1
last_score = score
scores+="</{}>\n".format(name)
return scores