From 40577beadce46fa0044043fbd4d37ebc72aaf828 Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Sat, 7 Mar 2020 10:34:01 +0300 Subject: [PATCH] ScoreStorage: Fix full combos with a worse score not saving --- public/src/js/scoresheet.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/public/src/js/scoresheet.js b/public/src/js/scoresheet.js index cf9887b..8a12ac7 100644 --- a/public/src/js/scoresheet.js +++ b/public/src/js/scoresheet.js @@ -861,16 +861,20 @@ class Scoresheet{ } saveScore(){ - if(!this.controller.autoPlayEnabled && this.resultsObj.points > 0){ + if(!this.controller.autoPlayEnabled){ + if(this.resultsObj.points < 0){ + this.resultsObj.points = 0 + } var title = this.controller.selectedSong.originalTitle var hash = this.controller.selectedSong.hash var difficulty = this.resultsObj.difficulty var oldScore = scoreStorage.get(hash, difficulty, true) + var clearReached = this.controller.game.rules.clearReached(this.resultsObj.gauge) + var crown = "" + if(clearReached){ + crown = this.resultsObj.bad === 0 ? "gold" : "silver" + } if(!oldScore || oldScore.points <= this.resultsObj.points){ - var crown = "" - if(this.controller.game.rules.clearReached(this.resultsObj.gauge)){ - crown = this.resultsObj.bad === 0 ? "gold" : "silver" - } if(oldScore && (oldScore.crown === "gold" || oldScore.crown === "silver" && !crown)){ crown = oldScore.crown } @@ -879,6 +883,9 @@ class Scoresheet{ delete this.resultsObj.difficulty delete this.resultsObj.gauge scoreStorage.add(hash, difficulty, this.resultsObj, true, title) + }else if(oldScore && (crown === "gold" && oldScore.crown !== "gold" || crown && !oldScore.crown)){ + oldScore.crown = crown + scoreStorage.add(hash, difficulty, oldScore, true, title) } } this.scoreSaved = true