1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 06:52:56 +08:00

Store mods as APIMods for the time being

This commit is contained in:
Dean Herbert 2021-10-29 15:13:33 +09:00
parent 06b6bcfd29
commit 17a83f701a
2 changed files with 11 additions and 9 deletions

View File

@ -135,7 +135,7 @@ namespace osu.Game.Tests.Visual.Gameplay
return new APIScoreInfo return new APIScoreInfo
{ {
OnlineID = 2553163309, OnlineID = 2553163309,
OnlineRulesetID = 0, RulesetID = 0,
Replay = replayAvailable, Replay = replayAvailable,
User = new User User = new User
{ {

View File

@ -61,10 +61,12 @@ namespace osu.Game.Online.API.Requests.Responses
public Dictionary<string, int> Statistics { get; set; } public Dictionary<string, int> Statistics { get; set; }
[JsonProperty(@"mode_int")] [JsonProperty(@"mode_int")]
public int OnlineRulesetID { get; set; } public int RulesetID { get; set; }
[JsonProperty(@"mods")] [JsonProperty(@"mods")]
public string[] Mods { get; set; } private string[] mods { set => Mods = value.Select(acronym => new APIMod { Acronym = acronym }); }
public IEnumerable<APIMod> Mods { get; set; }
[JsonProperty("rank")] [JsonProperty("rank")]
[JsonConverter(typeof(StringEnumConverter))] [JsonConverter(typeof(StringEnumConverter))]
@ -78,14 +80,14 @@ namespace osu.Game.Online.API.Requests.Responses
/// <returns></returns> /// <returns></returns>
public ScoreInfo CreateScoreInfo(RulesetStore rulesets, BeatmapInfo beatmap = null) public ScoreInfo CreateScoreInfo(RulesetStore rulesets, BeatmapInfo beatmap = null)
{ {
var ruleset = rulesets.GetRuleset(OnlineRulesetID); var ruleset = rulesets.GetRuleset(RulesetID);
var rulesetInstance = ruleset.CreateInstance(); var rulesetInstance = ruleset.CreateInstance();
var mods = Mods != null ? Mods.Select(acronym => rulesetInstance.CreateModFromAcronym(acronym)).Where(m => m != null).ToArray() : Array.Empty<Mod>(); var modInstances = Mods != null ? Mods.Select(apiMod => rulesetInstance.CreateModFromAcronym(apiMod.Acronym)).Where(m => m != null).ToArray() : Array.Empty<Mod>();
// all API scores provided by this class are considered to be legacy. // all API scores provided by this class are considered to be legacy.
mods = mods.Append(rulesetInstance.CreateMod<ModClassic>()).ToArray(); modInstances = modInstances.Append(rulesetInstance.CreateMod<ModClassic>()).ToArray();
var scoreInfo = new ScoreInfo var scoreInfo = new ScoreInfo
{ {
@ -96,11 +98,11 @@ namespace osu.Game.Online.API.Requests.Responses
OnlineScoreID = OnlineID, OnlineScoreID = OnlineID,
Date = Date, Date = Date,
PP = PP, PP = PP,
RulesetID = OnlineRulesetID, RulesetID = RulesetID,
Hash = Replay ? "online" : string.Empty, // todo: temporary? Hash = Replay ? "online" : string.Empty, // todo: temporary?
Rank = Rank, Rank = Rank,
Ruleset = ruleset, Ruleset = ruleset,
Mods = mods, Mods = modInstances,
}; };
if (beatmap != null) if (beatmap != null)
@ -142,7 +144,7 @@ namespace osu.Game.Online.API.Requests.Responses
return scoreInfo; return scoreInfo;
} }
public IRulesetInfo Ruleset => new RulesetInfo { ID = OnlineRulesetID }; public IRulesetInfo Ruleset => new RulesetInfo { ID = RulesetID };
IBeatmapInfo IScoreInfo.Beatmap => Beatmap; IBeatmapInfo IScoreInfo.Beatmap => Beatmap;
} }