def parseScores(scoresUnfiltered, gameid, filter): scoreList = [] scores = [x for x in scoresUnfiltered if x['user_id'] in filter] if len(scores) < 2: # Not counted if only 1 player played the map. return None scores = sorted(scores, key=lambda x: x['score'], reverse=True) for i in range(len(scores)): score_ = scores[i] score = Score() score.id = score_['id'] score.score = score_['score'] score.accuracy = score_['accuracy'] score.mods = ', '.join(score_['mods']) score.player_id = score_['user_id'] score.game_id = gameid score.position = i + 1 score.points = 1 - ((score.position - 1) / (len(scores) - 1))**1.2 #More lenient scoreList.append(score) return scoreList