2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-06-14 14:36:49 +08:00
|
|
|
|
|
2021-11-15 15:06:46 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2021-11-15 16:24:53 +08:00
|
|
|
|
using JetBrains.Annotations;
|
2021-11-15 15:06:29 +08:00
|
|
|
|
using Newtonsoft.Json;
|
2018-06-14 14:36:49 +08:00
|
|
|
|
using osu.Game.Rulesets.Difficulty;
|
2021-11-15 15:06:46 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-06-14 14:36:49 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Difficulty
|
|
|
|
|
{
|
|
|
|
|
public class OsuDifficultyAttributes : DifficultyAttributes
|
|
|
|
|
{
|
2021-12-18 04:39:03 +08:00
|
|
|
|
[JsonProperty("aim_difficulty")]
|
|
|
|
|
public double AimDifficulty { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
2021-12-18 04:39:03 +08:00
|
|
|
|
[JsonProperty("speed_difficulty")]
|
|
|
|
|
public double SpeedDifficulty { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
2021-12-18 04:39:03 +08:00
|
|
|
|
[JsonProperty("flashlight_difficulty")]
|
|
|
|
|
public double FlashlightDifficulty { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty("slider_factor")]
|
2021-11-10 08:59:28 +08:00
|
|
|
|
public double SliderFactor { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
2021-12-27 07:51:49 +08:00
|
|
|
|
[JsonProperty("aim_difficult_strain_count")]
|
|
|
|
|
public int AimDifficultStrainCount { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("speed_difficult_strain_count")]
|
|
|
|
|
public int SpeedDifficultStrainCount { get; set; }
|
|
|
|
|
|
2021-11-15 15:06:29 +08:00
|
|
|
|
[JsonProperty("approach_rate")]
|
2021-06-08 17:43:59 +08:00
|
|
|
|
public double ApproachRate { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty("overall_difficulty")]
|
2021-06-08 17:43:59 +08:00
|
|
|
|
public double OverallDifficulty { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
2021-09-24 22:02:19 +08:00
|
|
|
|
public double DrainRate { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
2021-06-08 17:43:59 +08:00
|
|
|
|
public int HitCircleCount { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
2021-10-14 01:04:34 +08:00
|
|
|
|
public int SliderCount { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
2021-06-08 17:43:59 +08:00
|
|
|
|
public int SpinnerCount { get; set; }
|
2021-11-15 15:06:46 +08:00
|
|
|
|
|
2021-11-15 17:11:07 +08:00
|
|
|
|
public override IEnumerable<(int attributeId, object value)> ToDatabaseAttributes()
|
2021-11-15 15:06:46 +08:00
|
|
|
|
{
|
2021-11-15 17:11:07 +08:00
|
|
|
|
foreach (var v in base.ToDatabaseAttributes())
|
2021-11-15 15:06:46 +08:00
|
|
|
|
yield return v;
|
|
|
|
|
|
2021-12-18 04:39:03 +08:00
|
|
|
|
yield return (ATTRIB_ID_AIM, AimDifficulty);
|
|
|
|
|
yield return (ATTRIB_ID_SPEED, SpeedDifficulty);
|
2021-11-17 19:31:18 +08:00
|
|
|
|
yield return (ATTRIB_ID_OVERALL_DIFFICULTY, OverallDifficulty);
|
|
|
|
|
yield return (ATTRIB_ID_APPROACH_RATE, ApproachRate);
|
|
|
|
|
yield return (ATTRIB_ID_MAX_COMBO, MaxCombo);
|
2021-12-18 04:39:03 +08:00
|
|
|
|
yield return (ATTRIB_ID_DIFFICULTY, StarRating);
|
2021-11-15 15:06:46 +08:00
|
|
|
|
|
2021-11-17 19:23:08 +08:00
|
|
|
|
if (ShouldSerializeFlashlightRating())
|
2021-12-18 04:39:03 +08:00
|
|
|
|
yield return (ATTRIB_ID_FLASHLIGHT, FlashlightDifficulty);
|
2021-11-15 15:06:46 +08:00
|
|
|
|
|
2021-11-17 19:31:18 +08:00
|
|
|
|
yield return (ATTRIB_ID_SLIDER_FACTOR, SliderFactor);
|
2021-11-15 15:06:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-15 17:11:07 +08:00
|
|
|
|
public override void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values)
|
2021-11-15 15:06:46 +08:00
|
|
|
|
{
|
2021-11-15 17:11:07 +08:00
|
|
|
|
base.FromDatabaseAttributes(values);
|
2021-11-15 15:06:46 +08:00
|
|
|
|
|
2021-12-18 04:39:03 +08:00
|
|
|
|
AimDifficulty = values[ATTRIB_ID_AIM];
|
|
|
|
|
SpeedDifficulty = values[ATTRIB_ID_SPEED];
|
2021-11-17 19:31:18 +08:00
|
|
|
|
OverallDifficulty = values[ATTRIB_ID_OVERALL_DIFFICULTY];
|
|
|
|
|
ApproachRate = values[ATTRIB_ID_APPROACH_RATE];
|
|
|
|
|
MaxCombo = (int)values[ATTRIB_ID_MAX_COMBO];
|
2021-12-18 04:39:03 +08:00
|
|
|
|
StarRating = values[ATTRIB_ID_DIFFICULTY];
|
|
|
|
|
FlashlightDifficulty = values.GetValueOrDefault(ATTRIB_ID_FLASHLIGHT);
|
2021-11-17 19:31:18 +08:00
|
|
|
|
SliderFactor = values[ATTRIB_ID_SLIDER_FACTOR];
|
2021-11-15 15:06:46 +08:00
|
|
|
|
}
|
2021-11-15 16:24:53 +08:00
|
|
|
|
|
2021-12-28 15:37:16 +08:00
|
|
|
|
#region Newtonsoft.Json implicit ShouldSerialize() methods
|
|
|
|
|
|
|
|
|
|
// The properties in this region are used implicitly by Newtonsoft.Json to not serialise certain fields in some cases.
|
|
|
|
|
// They rely on being named exactly the same as the corresponding fields (casing included) and as such should NOT be renamed
|
|
|
|
|
// unless the fields are also renamed.
|
|
|
|
|
|
2021-11-15 16:24:53 +08:00
|
|
|
|
[UsedImplicitly]
|
2021-11-17 19:23:08 +08:00
|
|
|
|
public bool ShouldSerializeFlashlightRating() => Mods.Any(m => m is ModFlashlight);
|
2021-12-28 15:37:16 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
2018-06-14 14:36:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|