Remove unnecessary constructure and make ruleset required

This commit is contained in:
Dean Herbert 2017-12-20 20:41:01 +09:00
parent 1b91f24044
commit c871a25dfa
2 changed files with 3 additions and 13 deletions

View File

@ -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;
}

View File

@ -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);
}