|
1 | 1 | // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. |
2 | 2 | // See the LICENCE file in the repository root for full licence text. |
3 | 3 |
|
| 4 | +using System; |
4 | 5 | using System.Collections.Generic; |
5 | 6 | using System.Linq; |
6 | 7 | using System.Threading; |
@@ -245,13 +246,26 @@ protected virtual IEnumerable<StatisticItem> CreateStatisticItems(ScoreInfo newS |
245 | 246 |
|
246 | 247 | // We may want to iterate on the following conditions further in the future |
247 | 248 |
|
248 | | - var localUserScore = AchievedScore ?? realm.Run(r => |
249 | | - r.GetAllLocalScoresForUser(api.LocalUser.Value.Id) |
250 | | - .Filter($@"{nameof(ScoreInfo.BeatmapInfo)}.{nameof(BeatmapInfo.ID)} == $0", newScore.BeatmapInfo.ID) |
251 | | - .AsEnumerable() |
252 | | - .OrderByDescending(score => score.Ruleset.MatchesOnlineID(newScore.BeatmapInfo.Ruleset)) |
253 | | - .ThenByDescending(score => score.Rank) |
254 | | - .FirstOrDefault()); |
| 249 | + var localUserScore = AchievedScore; |
| 250 | + |
| 251 | + if (localUserScore == null) |
| 252 | + { |
| 253 | + var localUserScores = realm.Run(r => |
| 254 | + r.GetAllLocalScoresForUser(api.LocalUser.Value.Id) |
| 255 | + .Filter($@"{nameof(ScoreInfo.BeatmapInfo)}.{nameof(BeatmapInfo.ID)} == $0", newScore.BeatmapInfo.ID) |
| 256 | + .AsEnumerable() |
| 257 | + .OrderByDescending(score => score.Ruleset.MatchesOnlineID(newScore.BeatmapInfo.Ruleset)) |
| 258 | + .ThenByDescending(score => score.Rank) |
| 259 | + .ToArray()); |
| 260 | + |
| 261 | + localUserScore = Array.Find(localUserScores, score => |
| 262 | + { |
| 263 | + return (score.Ruleset.OnlineID == newScore.BeatmapInfo!.Ruleset.OnlineID) |
| 264 | + && (score.Rank >= ScoreRank.C) |
| 265 | + && (!score.Mods.Any(m => (m.Type == ModType.Conversion) |
| 266 | + || m is not ModClassic)); |
| 267 | + }) ?? localUserScores.FirstOrDefault(); |
| 268 | + } |
255 | 269 |
|
256 | 270 | if (localUserScore == null) |
257 | 271 | preventTaggingReason = "Play the beatmap to contribute to beatmap tags!"; |
|
0 commit comments