mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 09:23:06 +08:00
Add databased fields to Score
This commit is contained in:
parent
09b79d736b
commit
3fe4a36845
@ -3,8 +3,12 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Users;
|
||||
@ -13,8 +17,11 @@ using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Scoring
|
||||
{
|
||||
public class Score
|
||||
public class Score : IHasFiles<ScoreFileInfo>, IHasPrimaryKey, ISoftDelete
|
||||
{
|
||||
[JsonIgnore]
|
||||
public int ID { get; set; }
|
||||
|
||||
public ScoreRank Rank { get; set; }
|
||||
|
||||
public double TotalScore { get; set; }
|
||||
@ -31,10 +38,30 @@ namespace osu.Game.Scoring
|
||||
|
||||
public RulesetInfo Ruleset { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
[JsonIgnore]
|
||||
public Mod[] Mods { get; set; } = { };
|
||||
|
||||
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]
|
||||
public User User;
|
||||
|
||||
public string UserString
|
||||
{
|
||||
get => User?.Username;
|
||||
set => User = new User { Username = value };
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public Replay Replay;
|
||||
|
||||
@ -45,5 +72,19 @@ namespace osu.Game.Scoring
|
||||
public DateTimeOffset Date;
|
||||
|
||||
public Dictionary<HitResult, object> Statistics = new Dictionary<HitResult, object>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
osu.Game/Scoring/ScoreFileInfo.cs
Normal file
21
osu.Game/Scoring/ScoreFileInfo.cs
Normal file
@ -0,0 +1,21 @@
|
||||
// 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.ComponentModel.DataAnnotations;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.IO;
|
||||
|
||||
namespace osu.Game.Scoring
|
||||
{
|
||||
public class ScoreFileInfo : INamedFileInfo, IHasPrimaryKey
|
||||
{
|
||||
public int ID { get; set; }
|
||||
|
||||
public int FileInfoID { get; set; }
|
||||
|
||||
public FileInfo FileInfo { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Filename { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user