Skip to content

Commit

Permalink
might fix tiny accuracy issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Joalor64GH authored Oct 23, 2024
1 parent 22345b4 commit 915f707
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions source/backend/HighScore.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ class HighScore {
if (songScores.exists(song)) {
if (songScores.get(song) < score) {
setScore(song, score);
if (rating >= 0) setRating(song, rating);
if (rating >= 0)
setRating(song, rating);
}
} else {
setScore(song, score);
if (rating >= 0) setRating(song, rating);
if (rating >= 0)
setRating(song, rating);
}
}

Expand Down
3 changes: 3 additions & 0 deletions source/backend/Utilities.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class Utilities {
return Math.max(min, Math.min(max, value));

public static function truncateFloat(number:Float, precision:Int):Float {
if (precision < 1)
return Math.ffloor(number);

var num = number;
num = num * Math.pow(10, precision);
num = Math.round(num) / Math.pow(10, precision);
Expand Down
2 changes: 1 addition & 1 deletion source/states/AchievementsState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class AchievementsState extends ExtendableState {
+ achievementArray[curSelected].hint
+ '\nDate Unlocked: '
+ stat.date
+ 'Song Unlocked: '
+ '\nSong Unlocked: '
+ stat.song : 'This achievement has not been unlocked yet!'
+ '\nHint: '
+ achievementArray[curSelected].hint;
Expand Down
5 changes: 3 additions & 2 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ class PlayState extends ExtendableState {

for (i in 0...justPressed.length) {
if (justPressed[i]) {
strumline.members[i].press();
if (!SaveData.settings.botPlay)
strumline.members[i].press();
if (SaveData.settings.antiMash) {
FlxG.sound.play(Paths.sound('miss${FlxG.random.int(1, 4)}'), 0.65);
isPerfect = false;
Expand Down Expand Up @@ -698,7 +699,7 @@ class PlayState extends ExtendableState {
}

if (!SaveData.settings.botPlay)
HighScore.saveScore(song.song, score, accuracy);
HighScore.saveScore(song.song, score, Utilities.truncateFloat(accuracy, 2));
new FlxTimer().start(0.5, (tmr:FlxTimer) -> {
persistentUpdate = true;
openSubState(new ResultsSubState(rank, score, accuracy));
Expand Down
2 changes: 1 addition & 1 deletion source/states/SongSelectState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class SongSelectState extends ExtendableState {
lerpRating = intendedRating;

if (!isResetting)
panelTxt.text = Localization.get("scoreTxt", SaveData.settings.lang) + lerpScore + "(" + lerpRating + ")%" + " // " + Localization.get("diffTxt", SaveData.settings.lang)
panelTxt.text = Localization.get("scoreTxt", SaveData.settings.lang) + lerpScore + " (" + Utilities.truncateFloat(lerpRating * 100, 2) + ")%" + " // " + Localization.get("diffTxt", SaveData.settings.lang)
+ Std.string(songListData.songs[currentIndex].diff) + "/5";

if (!lockInputs) {
Expand Down

0 comments on commit 915f707

Please sign in to comment.