Skip to content

Commit

Permalink
Merge pull request #19126 from peppy/lazer-leaderboards
Browse files Browse the repository at this point in the history
Show leaderboard scores from new data source
  • Loading branch information
peppy authored Jul 15, 2022
2 parents 288fdbd + 4b253f8 commit cbbc8fd
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 14 deletions.
12 changes: 8 additions & 4 deletions osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,18 @@ private APIScoresCollection createScores()
}
};

const int initial_great_count = 2000;

int greatCount = initial_great_count;

foreach (var s in scores.Scores)
{
s.Statistics = new Dictionary<HitResult, int>
{
{ HitResult.Great, RNG.Next(2000) },
{ HitResult.Ok, RNG.Next(2000) },
{ HitResult.Meh, RNG.Next(2000) },
{ HitResult.Miss, RNG.Next(2000) }
{ HitResult.Great, greatCount -= 100 },
{ HitResult.Ok, RNG.Next(100) },
{ HitResult.Meh, RNG.Next(100) },
{ HitResult.Miss, initial_great_count - greatCount }
};
}

Expand Down
1 change: 0 additions & 1 deletion osu.Game/Database/EFToRealmMigrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ private void migrateScores(OsuDbContext db)
TotalScore = score.TotalScore,
MaxCombo = score.MaxCombo,
Accuracy = score.Accuracy,
HasReplay = ((IScoreInfo)score).HasReplay,
Date = score.Date,
PP = score.PP,
Rank = score.Rank,
Expand Down
3 changes: 2 additions & 1 deletion osu.Game/Database/RealmAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ public class RealmAccess : IDisposable
/// 13 2022-01-13 Final migration of beatmaps and scores to realm (multiple new storage fields).
/// 14 2022-03-01 Added BeatmapUserSettings to BeatmapInfo.
/// 15 2022-07-13 Added LastPlayed to BeatmapInfo.
/// 16 2022-07-15 Removed HasReplay from ScoreInfo.
/// </summary>
private const int schema_version = 15;
private const int schema_version = 16;

/// <summary>
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods.
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Online/API/Requests/GetScoresRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public GetScoresRequest(IBeatmapInfo beatmapInfo, IRulesetInfo ruleset, BeatmapL
this.mods = mods ?? Array.Empty<IMod>();
}

protected override string Target => $@"beatmaps/{beatmapInfo.OnlineID}/scores{createQueryParameters()}";
protected override string Target => $@"beatmaps/{beatmapInfo.OnlineID}/solo-scores{createQueryParameters()}";

private string createQueryParameters()
{
Expand Down
6 changes: 1 addition & 5 deletions osu.Game/Online/API/Requests/Responses/SoloScoreInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ public ScoreInfo ToScoreInfo(RulesetStore rulesets, BeatmapInfo? beatmap = null)

var mods = Mods.Select(apiMod => rulesetInstance.CreateModFromAcronym(apiMod.Acronym)).Where(m => m != null).ToArray();

// all API scores provided by this class are considered to be legacy.
mods = mods.Append(rulesetInstance.CreateMod<ModClassic>()).ToArray();

var scoreInfo = ToScoreInfo(mods);

scoreInfo.Ruleset = ruleset;
Expand All @@ -132,8 +129,7 @@ public ScoreInfo ToScoreInfo(RulesetStore rulesets, BeatmapInfo? beatmap = null)
Rank = Rank,
Statistics = Statistics,
Date = EndedAt ?? DateTimeOffset.Now,
Hash = "online", // TODO: temporary?
HasReplay = HasReplay,
Hash = HasReplay ? "online" : string.Empty, // TODO: temporary?
Mods = mods,
PP = PP,
};
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Scoring/ScoreInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ScoreInfo : RealmObject, IHasGuidPrimaryKey, IHasRealmFiles, ISoftD

public double Accuracy { get; set; }

public bool HasReplay { get; set; }
public bool HasReplay => !string.IsNullOrEmpty(Hash);

public DateTimeOffset Date { get; set; }

Expand Down
4 changes: 4 additions & 0 deletions osu.Game/Scoring/ScoreRank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ namespace osu.Game.Scoring
{
public enum ScoreRank
{
// TODO: Localisable?
[Description(@"F")]
F = -1,

[LocalisableDescription(typeof(BeatmapsStrings), nameof(BeatmapsStrings.RankD))]
[Description(@"D")]
D,
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Screens/Ranking/ReplayDownloadButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private ReplayAvailability replayAvailability
if (State.Value == DownloadState.LocallyAvailable)
return ReplayAvailability.Local;

if (!string.IsNullOrEmpty(Score.Value?.Hash))
if (Score.Value?.HasReplay == true)
return ReplayAvailability.Online;

return ReplayAvailability.NotAvailable;
Expand Down

0 comments on commit cbbc8fd

Please sign in to comment.