mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 12:35:34 +08:00
Ensure APIScoreInfo.Mods
is non-null
This commit is contained in:
parent
caa9d8997b
commit
3a5aed1182
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -67,7 +68,8 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
[JsonProperty(@"mods")]
|
[JsonProperty(@"mods")]
|
||||||
private string[] mods { set => Mods = value.Select(acronym => new APIMod { Acronym = acronym }); }
|
private string[] mods { set => Mods = value.Select(acronym => new APIMod { Acronym = acronym }); }
|
||||||
|
|
||||||
public IEnumerable<APIMod> Mods { get; set; }
|
[NotNull]
|
||||||
|
public IEnumerable<APIMod> Mods { get; set; } = Array.Empty<APIMod>();
|
||||||
|
|
||||||
[JsonProperty("rank")]
|
[JsonProperty("rank")]
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
@ -85,7 +87,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
|
|
||||||
var rulesetInstance = ruleset.CreateInstance();
|
var rulesetInstance = ruleset.CreateInstance();
|
||||||
|
|
||||||
var modInstances = Mods != null ? Mods.Select(apiMod => rulesetInstance.CreateModFromAcronym(apiMod.Acronym)).Where(m => m != null).ToArray() : Array.Empty<Mod>();
|
var modInstances = Mods.Select(apiMod => rulesetInstance.CreateModFromAcronym(apiMod.Acronym)).Where(m => m != null).ToArray();
|
||||||
|
|
||||||
// all API scores provided by this class are considered to be legacy.
|
// all API scores provided by this class are considered to be legacy.
|
||||||
modInstances = modInstances.Append(rulesetInstance.CreateMod<ModClassic>()).ToArray();
|
modInstances = modInstances.Append(rulesetInstance.CreateMod<ModClassic>()).ToArray();
|
||||||
|
Loading…
Reference in New Issue
Block a user