mirror of https://github.com/ppy/osu
Remove unnecessary constructure and make ruleset required
This commit is contained in:
parent
1b91f24044
commit
c871a25dfa
|
@ -21,16 +21,6 @@ public class GetScoresRequest : APIRequest<GetScoresResponse>
|
|||
private readonly LeaderboardScope scope;
|
||||
private readonly RulesetInfo ruleset;
|
||||
|
||||
public GetScoresRequest(BeatmapInfo beatmap)
|
||||
{
|
||||
if (!beatmap.OnlineBeatmapID.HasValue)
|
||||
throw new InvalidOperationException($"Cannot lookup a beatmap's scores without having a populated {nameof(BeatmapInfo.OnlineBeatmapID)}.");
|
||||
|
||||
this.beatmap = beatmap;
|
||||
|
||||
Success += onSuccess;
|
||||
}
|
||||
|
||||
public GetScoresRequest(BeatmapInfo beatmap, RulesetInfo ruleset, LeaderboardScope scope = LeaderboardScope.Global)
|
||||
{
|
||||
if (!beatmap.OnlineBeatmapID.HasValue)
|
||||
|
@ -41,7 +31,7 @@ public GetScoresRequest(BeatmapInfo beatmap, RulesetInfo ruleset, LeaderboardSco
|
|||
|
||||
this.beatmap = beatmap;
|
||||
this.scope = scope;
|
||||
this.ruleset = ruleset;
|
||||
this.ruleset = ruleset ?? throw new ArgumentNullException(nameof(ruleset));
|
||||
|
||||
Success += onSuccess;
|
||||
}
|
||||
|
@ -57,7 +47,7 @@ protected override WebRequest CreateWebRequest()
|
|||
var req = base.CreateWebRequest();
|
||||
|
||||
req.AddParameter(@"type", scope.ToString().ToLowerInvariant());
|
||||
req.AddParameter(@"mode", ruleset?.ShortName ?? @"osu");
|
||||
req.AddParameter(@"mode", ruleset.ShortName);
|
||||
|
||||
return req;
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ private void beatmapChanged(WorkingBeatmap newBeatmap)
|
|||
if (!api.IsLoggedIn)
|
||||
return;
|
||||
|
||||
lastRequest = new GetScoresRequest(newBeatmap.BeatmapInfo);
|
||||
lastRequest = new GetScoresRequest(newBeatmap.BeatmapInfo, newBeatmap.BeatmapInfo.Ruleset);
|
||||
lastRequest.Success += res => res.Scores.ForEach(s => scores.Add(new PerformanceDisplay(s, newBeatmap.Beatmap)));
|
||||
api.Queue(lastRequest);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue