1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 17:43:21 +08:00

Initialise all parameters is paramaterless constructor for now for added safety

This commit is contained in:
Dean Herbert 2022-01-17 13:51:30 +09:00
parent 11ca1b6e7b
commit 744084b418
2 changed files with 27 additions and 21 deletions

View File

@ -31,11 +31,11 @@ namespace osu.Game.Beatmaps
public string DifficultyName { get; set; } = string.Empty; public string DifficultyName { get; set; } = string.Empty;
public RulesetInfo Ruleset { get; set; } = null!; public RulesetInfo Ruleset { get; set; }
public BeatmapDifficulty Difficulty { get; set; } = new BeatmapDifficulty(); public BeatmapDifficulty Difficulty { get; set; }
public BeatmapMetadata Metadata { get; set; } = new BeatmapMetadata(); public BeatmapMetadata Metadata { get; set; }
[IgnoreMap] [IgnoreMap]
[Backlink(nameof(ScoreInfo.BeatmapInfo))] [Backlink(nameof(ScoreInfo.BeatmapInfo))]
@ -51,6 +51,9 @@ namespace osu.Game.Beatmaps
[UsedImplicitly] [UsedImplicitly]
public BeatmapInfo() // TODO: consider removing this and migrating all usages to ctor with parameters. public BeatmapInfo() // TODO: consider removing this and migrating all usages to ctor with parameters.
{ {
Ruleset = new RulesetInfo();
Difficulty = new BeatmapDifficulty();
Metadata = new BeatmapMetadata();
} }
public BeatmapSetInfo? BeatmapSet { get; set; } public BeatmapSetInfo? BeatmapSet { get; set; }

View File

@ -32,19 +32,33 @@ namespace osu.Game.Scoring
[PrimaryKey] [PrimaryKey]
public Guid ID { get; set; } = Guid.NewGuid(); public Guid ID { get; set; } = Guid.NewGuid();
public BeatmapInfo BeatmapInfo { get; set; }
public RulesetInfo Ruleset { get; set; }
public IList<RealmNamedFileUsage> Files { get; } = null!; public IList<RealmNamedFileUsage> Files { get; } = null!;
public string Hash { get; set; } = string.Empty; public string Hash { get; set; } = string.Empty;
public bool DeletePending { get; set; } public bool DeletePending { get; set; }
public bool Equals(ScoreInfo other) => other.ID == ID; public long TotalScore { get; set; }
public int MaxCombo { get; set; }
public double Accuracy { get; set; }
public bool HasReplay { get; set; }
public DateTimeOffset Date { get; set; }
public double? PP { get; set; }
[Indexed] [Indexed]
public long OnlineID { get; set; } = -1; public long OnlineID { get; set; } = -1;
[MapTo("User")] [MapTo("User")]
public RealmUser RealmUser { get; set; } = new RealmUser(); public RealmUser RealmUser { get; set; }
[MapTo("Mods")] [MapTo("Mods")]
public string ModsJson { get; set; } = string.Empty; public string ModsJson { get; set; } = string.Empty;
@ -62,6 +76,9 @@ namespace osu.Game.Scoring
[UsedImplicitly] [UsedImplicitly]
public ScoreInfo() // TODO: consider removing this and migrating all usages to ctor with parameters. public ScoreInfo() // TODO: consider removing this and migrating all usages to ctor with parameters.
{ {
Ruleset = new RulesetInfo();
RealmUser = new RealmUser();
BeatmapInfo = new BeatmapInfo();
} }
// TODO: this is a bit temporary to account for the fact that this class is used to ferry API user data to certain UI components. // TODO: this is a bit temporary to account for the fact that this class is used to ferry API user data to certain UI components.
@ -88,22 +105,6 @@ namespace osu.Game.Scoring
} }
} }
public long TotalScore { get; set; }
public int MaxCombo { get; set; }
public double Accuracy { get; set; }
public bool HasReplay { get; set; }
public DateTimeOffset Date { get; set; }
public double? PP { get; set; }
public BeatmapInfo BeatmapInfo { get; set; } = null!;
public RulesetInfo Ruleset { get; set; } = null!;
public ScoreRank Rank public ScoreRank Rank
{ {
get => (ScoreRank)RankInt; get => (ScoreRank)RankInt;
@ -275,6 +276,8 @@ namespace osu.Game.Scoring
#endregion #endregion
public bool Equals(ScoreInfo other) => other.ID == ID;
public override string ToString() => this.GetDisplayTitle(); public override string ToString() => this.GetDisplayTitle();
} }
} }