1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:07:25 +08:00
osu-lazer/osu.Game/Scoring/Score.cs

101 lines
2.6 KiB
C#
Raw Normal View History

2018-04-13 17:19:50 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
2018-11-28 15:39:08 +08:00
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using JetBrains.Annotations;
2018-09-28 17:29:49 +08:00
using Newtonsoft.Json;
2018-04-13 17:19:50 +08:00
using osu.Game.Beatmaps;
2018-11-28 15:39:08 +08:00
using osu.Game.Database;
2018-11-28 16:20:37 +08:00
using osu.Game.Replays;
2018-11-28 15:33:42 +08:00
using osu.Game.Rulesets;
2018-04-13 17:19:50 +08:00
using osu.Game.Rulesets.Mods;
using osu.Game.Users;
2018-11-28 15:33:42 +08:00
using osu.Game.Rulesets.Scoring;
2018-04-13 17:19:50 +08:00
2018-11-28 15:12:57 +08:00
namespace osu.Game.Scoring
2018-04-13 17:19:50 +08:00
{
2018-11-28 15:39:08 +08:00
public class Score : IHasFiles<ScoreFileInfo>, IHasPrimaryKey, ISoftDelete
2018-04-13 17:19:50 +08:00
{
2018-11-28 15:39:08 +08:00
[JsonIgnore]
public int ID { get; set; }
2018-04-13 17:19:50 +08:00
public ScoreRank Rank { get; set; }
public double TotalScore { get; set; }
public double Accuracy { get; set; }
public double Health { get; set; } = 1;
public double? PP { get; set; }
public int MaxCombo { get; set; }
public int Combo { get; set; }
2018-11-28 16:26:46 +08:00
public int RulesetID { get; set; }
2018-04-13 17:19:50 +08:00
public RulesetInfo Ruleset { get; set; }
2018-11-28 15:39:08 +08:00
[NotMapped]
[JsonIgnore]
2018-04-13 17:19:50 +08:00
public Mod[] Mods { get; set; } = { };
2018-11-28 15:39:08 +08:00
public string ModsString
{
get => JsonConvert.SerializeObject(Mods);
set
{
var deserialized = JsonConvert.DeserializeObject<SerializableMod[]>(value);
Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => deserialized.Any(d => d.ShortenedName == mod.ShortenedName)).ToArray();
}
}
[NotMapped]
[JsonIgnore]
2018-04-13 17:19:50 +08:00
public User User;
2018-11-28 15:39:08 +08:00
public string UserString
{
get => User?.Username;
set => User = new User { Username = value };
}
2018-09-28 17:29:49 +08:00
[JsonIgnore]
2018-04-13 17:19:50 +08:00
public Replay Replay;
public int BeatmapInfoID { get; set; }
public BeatmapInfo BeatmapInfo;
2018-04-13 17:19:50 +08:00
public long OnlineScoreID;
public DateTimeOffset Date;
public Dictionary<HitResult, object> Statistics = new Dictionary<HitResult, object>();
2018-11-28 15:39:08 +08:00
/// <summary>
/// MD5 is kept for legacy support.
/// </summary>
[JsonProperty("file_md5")]
public string MD5Hash { get; set; }
2018-11-28 15:39:08 +08:00
public List<ScoreFileInfo> Files { get; set; }
public bool DeletePending { get; set; }
[UsedImplicitly]
private class SerializableMod : Mod
{
public override string Name => ShortenedName;
public override string ShortenedName { get; } = string.Empty;
public override double ScoreMultiplier => 0;
}
2018-04-13 17:19:50 +08:00
}
}