Use a method to apply a beatmap, its ruleset and the mods.

This commit is contained in:
MrTheMake
2017-09-08 12:17:16 +02:00
parent 01553fc9ef
commit 526ee107b8
2 changed files with 7 additions and 7 deletions

View File

@ -23,12 +23,7 @@ namespace osu.Game.Online.API.Requests
private void onSuccess(GetScoresResponse r) private void onSuccess(GetScoresResponse r)
{ {
foreach (OnlineScore score in r.Scores) foreach (OnlineScore score in r.Scores)
{ score.ApplyBeatmap(beatmap);
score.Beatmap = beatmap;
score.Ruleset = beatmap.Ruleset;
score.ResolveModString();
}
} }
protected override WebRequest CreateWebRequest() protected override WebRequest CreateWebRequest()

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Game.Beatmaps;
using osu.Game.Users; using osu.Game.Users;
using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Replays;
@ -82,8 +83,12 @@ namespace osu.Game.Rulesets.Scoring
[JsonProperty(@"mods")] [JsonProperty(@"mods")]
private string[] modStrings { get; set; } private string[] modStrings { get; set; }
public void ResolveModString() public void ApplyBeatmap(BeatmapInfo beatmap)
{ {
Beatmap = beatmap;
Ruleset = beatmap.Ruleset;
// Evaluate the mod string
Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray(); Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray();
} }
} }