Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. def setCompletedStatus(self, b = None):
  2. """
  3. Set this score completed status and rankedScoreIncrease
  4. """
  5. self.completed = 0
  6.  
  7. # Create beatmap object
  8. if b is None:
  9. b = beatmap.beatmap(self.fileMd5, 0)
  10.  
  11. if self.passed == True and scoreUtils.isRankable(self.mods):
  12. # Get userID
  13. userID = userUtils.getID(self.playerName)
  14.  
  15. # Make sure we don't have another score identical to this one
  16. duplicate = glob.db.fetch("SELECT id FROM scores_relax WHERE userid = %s AND beatmap_md5 = %s AND play_mode = %s AND score = %s LIMIT 1", [userID, self.fileMd5, self.gameMode, self.score])
  17. if duplicate is not None:
  18. # Found same score in db. Don't save this score.
  19. self.completed = -1
  20. return
  21.  
  22. # No duplicates found.
  23. # Get right "completed" value
  24. personalBest = glob.db.fetch("SELECT id, pp, score FROM scores_relax WHERE userid = %s AND beatmap_md5 = %s AND play_mode = %s AND completed = 3 LIMIT 1", [userID, self.fileMd5, self.gameMode])
  25. if personalBest is None:
  26. # This is our first score on this map, so it's our best score
  27. self.completed = 3
  28. self.rankedScoreIncrease = self.score
  29. self.oldPersonalBest = 0
  30. else:
  31. self.calculatePP() # Compare personal best's score with current score
  32. if b.rankedStatus == rankedStatuses.RANKED or b.rankedStatus == rankedStatuses.APPROVED:
  33. if self.pp > personalBest["pp"]:
  34. # New best score
  35. self.completed = 3
  36. self.rankedScoreIncrease = self.score-personalBest["score"]
  37. self.oldPersonalBest = personalBest["id"]
  38. else:
  39. self.completed = 2
  40. self.rankedScoreIncrease = 0
  41. self.oldPersonalBest = 0
  42. elif b.rankedStatus == rankedStatuses.LOVED:
  43. if self.score > personalBest["score"]:
  44. # New best score
  45. self.completed = 3
  46. self.rankedScoreIncrease = self.score-personalBest["score"]
  47. self.oldPersonalBest = personalBest["id"]
  48. else:
  49. self.completed = 2
  50. self.rankedScoreIncrease = 0
  51. self.oldPersonalBest = 0
  52.  
  53. log.info("Completed status: {}".format(self.completed))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement