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

Avoid json serialisation of aggregate helper properties

Also avoids `throw`ing when there are no beatmaps available. Until now
this wasn't an issue due to the `Beatmaps` list being null instead of empty.
This commit is contained in:
Dean Herbert 2021-11-24 13:34:52 +09:00
parent 8c60f37508
commit a3fdab34d5

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
using Newtonsoft.Json;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions; using osu.Game.Extensions;
@ -30,6 +31,7 @@ namespace osu.Game.Beatmaps
public BeatmapMetadata Metadata { get; set; } public BeatmapMetadata Metadata { get; set; }
[NotNull]
public List<BeatmapInfo> Beatmaps { get; } = new List<BeatmapInfo>(); public List<BeatmapInfo> Beatmaps { get; } = new List<BeatmapInfo>();
public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None; public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None;
@ -40,17 +42,20 @@ namespace osu.Game.Beatmaps
/// <summary> /// <summary>
/// The maximum star difficulty of all beatmaps in this set. /// The maximum star difficulty of all beatmaps in this set.
/// </summary> /// </summary>
public double MaxStarDifficulty => Beatmaps?.Max(b => b.StarRating) ?? 0; [JsonIgnore]
public double MaxStarDifficulty => Beatmaps.Count == 0 ? 0 : Beatmaps.Max(b => b.StarRating);
/// <summary> /// <summary>
/// The maximum playable length in milliseconds of all beatmaps in this set. /// The maximum playable length in milliseconds of all beatmaps in this set.
/// </summary> /// </summary>
public double MaxLength => Beatmaps?.Max(b => b.Length) ?? 0; [JsonIgnore]
public double MaxLength => Beatmaps.Count == 0 ? 0 : Beatmaps.Max(b => b.Length);
/// <summary> /// <summary>
/// The maximum BPM of all beatmaps in this set. /// The maximum BPM of all beatmaps in this set.
/// </summary> /// </summary>
public double MaxBPM => Beatmaps?.Max(b => b.BPM) ?? 0; [JsonIgnore]
public double MaxBPM => Beatmaps.Count == 0 ? 0 : Beatmaps.Max(b => b.BPM);
[NotMapped] [NotMapped]
public bool DeletePending { get; set; } public bool DeletePending { get; set; }