From 0dd23c46b04caebae04a115ce6c7f1591ae21e6f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 Nov 2021 23:18:37 +0900 Subject: [PATCH] Add basic `RealmScore` implementation --- osu.Game/Models/RealmScore.cs | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 osu.Game/Models/RealmScore.cs diff --git a/osu.Game/Models/RealmScore.cs b/osu.Game/Models/RealmScore.cs new file mode 100644 index 0000000000..323bd2393c --- /dev/null +++ b/osu.Game/Models/RealmScore.cs @@ -0,0 +1,68 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using osu.Framework.Testing; +using osu.Game.Beatmaps; +using osu.Game.Database; +using osu.Game.Rulesets; +using osu.Game.Scoring; +using osu.Game.Users; +using Realms; + +#nullable enable + +namespace osu.Game.Models +{ + [ExcludeFromDynamicCompile] + [MapTo("Score")] + public class RealmScore : RealmObject, IHasGuidPrimaryKey, IHasRealmFiles, ISoftDelete, IEquatable, IScoreInfo + { + [PrimaryKey] + public Guid ID { get; set; } = Guid.NewGuid(); + + public IList Files { get; } = null!; + + public string Hash { get; set; } = string.Empty; + + public bool DeletePending { get; set; } + + public bool Equals(RealmScore other) => other.ID == ID; + + [Indexed] + public long OnlineID { get; set; } = -1; + + public RealmUser User { get; set; } = null!; + + 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; } = null; + + public RealmBeatmap Beatmap { get; set; } = null!; + + public RealmRuleset Ruleset { get; set; } = null!; + + public ScoreRank Rank + { + get => (ScoreRank)RankInt; + set => RankInt = (int)value; + } + + [MapTo(nameof(Rank))] + public int RankInt { get; set; } + + IRulesetInfo IScoreInfo.Ruleset => Ruleset; + IBeatmapInfo IScoreInfo.Beatmap => Beatmap; + IUser IScoreInfo.User => User; + IEnumerable IHasNamedFiles.Files => Files; + } +}