Skip to content

Commit

Permalink
Use classic score in total score processor
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach committed Sep 28, 2023
1 parent 84c371f commit 622df85
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ public static ScoreItem CreateTestScore(int? rulesetId = null, int? beatmapId =
{ HitResult.Perfect, 5 },
{ HitResult.LargeBonus, 0 }
},
MaximumStatistics =
{
{ HitResult.Perfect, 5 },
{ HitResult.LargeBonus, 2 }
},
Passed = true
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public void TestTotalScoreIncrease()
WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", (int?)null, CancellationToken);

PushToQueueAndWaitForProcess(CreateTestScore());
WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 100000, CancellationToken);
WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 10081, CancellationToken);

PushToQueueAndWaitForProcess(CreateTestScore());
WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 200000, CancellationToken);
WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 20162, CancellationToken);
}

[Fact]
Expand Down Expand Up @@ -45,12 +45,12 @@ public void TestTotalScoreReprocessDoesntIncrease()
WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", (int?)null, CancellationToken);

PushToQueueAndWaitForProcess(score);
WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 100000, CancellationToken);
WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 10081, CancellationToken);

score.MarkProcessed();

PushToQueueAndWaitForProcess(score);
WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 100000, CancellationToken);
WaitForDatabaseState("SELECT total_score FROM osu_user_stats WHERE user_id = 2", 10081, CancellationToken);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using JetBrains.Annotations;
using MySqlConnector;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring.Legacy;
using osu.Server.Queues.ScoreStatisticsProcessor.Models;

namespace osu.Server.Queues.ScoreStatisticsProcessor.Processors
Expand All @@ -19,12 +21,12 @@ public class TotalScoreProcessor : IProcessor
public void RevertFromUserStats(SoloScoreInfo score, UserStats userStats, int previousVersion, MySqlConnection conn, MySqlTransaction transaction)
{
if (previousVersion >= 2)
userStats.total_score -= score.TotalScore;
userStats.total_score -= score.GetDisplayScore(ScoringMode.Classic);
}

public void ApplyToUserStats(SoloScoreInfo score, UserStats userStats, MySqlConnection conn, MySqlTransaction transaction)
{
userStats.total_score += score.TotalScore;
userStats.total_score += score.GetDisplayScore(ScoringMode.Classic);
}

public void ApplyGlobal(SoloScoreInfo score, MySqlConnection conn)
Expand Down

0 comments on commit 622df85

Please sign in to comment.