Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def setCompletedStatus(self, b = None):
- """
- Set this score completed status and rankedScoreIncrease
- """
- self.completed = 0
- # Create beatmap object
- if b is None:
- b = beatmap.beatmap(self.fileMd5, 0)
- if self.passed == True and scoreUtils.isRankable(self.mods):
- # Get userID
- userID = userUtils.getID(self.playerName)
- # Make sure we don't have another score identical to this one
- 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])
- if duplicate is not None:
- # Found same score in db. Don't save this score.
- self.completed = -1
- return
- # No duplicates found.
- # Get right "completed" value
- 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])
- if personalBest is None:
- # This is our first score on this map, so it's our best score
- self.completed = 3
- self.rankedScoreIncrease = self.score
- self.oldPersonalBest = 0
- else:
- self.calculatePP() # Compare personal best's score with current score
- if b.rankedStatus == rankedStatuses.RANKED or b.rankedStatus == rankedStatuses.APPROVED:
- if self.pp > personalBest["pp"]:
- # New best score
- self.completed = 3
- self.rankedScoreIncrease = self.score-personalBest["score"]
- self.oldPersonalBest = personalBest["id"]
- else:
- self.completed = 2
- self.rankedScoreIncrease = 0
- self.oldPersonalBest = 0
- elif b.rankedStatus == rankedStatuses.LOVED:
- if self.score > personalBest["score"]:
- # New best score
- self.completed = 3
- self.rankedScoreIncrease = self.score-personalBest["score"]
- self.oldPersonalBest = personalBest["id"]
- else:
- self.completed = 2
- self.rankedScoreIncrease = 0
- self.oldPersonalBest = 0
- log.info("Completed status: {}".format(self.completed))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement