2019-01-24 08:43:03 +00: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 06:36:49 +00:00
|
|
|
|
|
2021-11-15 07:06:46 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2021-11-15 08:24:53 +00:00
|
|
|
|
using JetBrains.Annotations;
|
2021-11-15 07:06:29 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2018-06-14 06:36:49 +00:00
|
|
|
|
using osu.Game.Rulesets.Difficulty;
|
2021-11-15 07:06:46 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-06-14 06:36:49 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Difficulty
|
|
|
|
|
{
|
|
|
|
|
public class OsuDifficultyAttributes : DifficultyAttributes
|
|
|
|
|
{
|
2021-12-17 20:39:03 +00:00
|
|
|
|
[JsonProperty("aim_difficulty")]
|
|
|
|
|
public double AimDifficulty { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
2021-12-17 20:39:03 +00:00
|
|
|
|
[JsonProperty("speed_difficulty")]
|
|
|
|
|
public double SpeedDifficulty { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
2021-12-17 20:39:03 +00:00
|
|
|
|
[JsonProperty("flashlight_difficulty")]
|
|
|
|
|
public double FlashlightDifficulty { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
|
|
|
|
[JsonProperty("slider_factor")]
|
2021-11-10 00:59:28 +00:00
|
|
|
|
public double SliderFactor { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
|
|
|
|
[JsonProperty("approach_rate")]
|
2021-06-08 09:43:59 +00:00
|
|
|
|
public double ApproachRate { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
|
|
|
|
[JsonProperty("overall_difficulty")]
|
2021-06-08 09:43:59 +00:00
|
|
|
|
public double OverallDifficulty { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
2021-09-24 14:02:19 +00:00
|
|
|
|
public double DrainRate { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
2021-06-08 09:43:59 +00:00
|
|
|
|
public int HitCircleCount { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
2021-10-13 17:04:34 +00:00
|
|
|
|
public int SliderCount { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
2021-06-08 09:43:59 +00:00
|
|
|
|
public int SpinnerCount { get; set; }
|
2021-11-15 07:06:46 +00:00
|
|
|
|
|
2021-11-15 09:11:07 +00:00
|
|
|
|
public override IEnumerable<(int attributeId, object value)> ToDatabaseAttributes()
|
2021-11-15 07:06:46 +00:00
|
|
|
|
{
|
2021-11-15 09:11:07 +00:00
|
|
|
|
foreach (var v in base.ToDatabaseAttributes())
|
2021-11-15 07:06:46 +00:00
|
|
|
|
yield return v;
|
|
|
|
|
|
2021-12-17 20:39:03 +00:00
|
|
|
|
yield return (ATTRIB_ID_AIM, AimDifficulty);
|
|
|
|
|
yield return (ATTRIB_ID_SPEED, SpeedDifficulty);
|
2021-11-17 11:31:18 +00:00
|
|
|
|
yield return (ATTRIB_ID_OVERALL_DIFFICULTY, OverallDifficulty);
|
|
|
|
|
yield return (ATTRIB_ID_APPROACH_RATE, ApproachRate);
|
|
|
|
|
yield return (ATTRIB_ID_MAX_COMBO, MaxCombo);
|
2021-12-17 20:39:03 +00:00
|
|
|
|
yield return (ATTRIB_ID_DIFFICULTY, StarRating);
|
2021-11-15 07:06:46 +00:00
|
|
|
|
|
2021-11-17 11:23:08 +00:00
|
|
|
|
if (ShouldSerializeFlashlightRating())
|
2021-12-17 20:39:03 +00:00
|
|
|
|
yield return (ATTRIB_ID_FLASHLIGHT, FlashlightDifficulty);
|
2021-11-15 07:06:46 +00:00
|
|
|
|
|
2021-11-17 11:31:18 +00:00
|
|
|
|
yield return (ATTRIB_ID_SLIDER_FACTOR, SliderFactor);
|
2021-11-15 07:06:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-15 09:11:07 +00:00
|
|
|
|
public override void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values)
|
2021-11-15 07:06:46 +00:00
|
|
|
|
{
|
2021-11-15 09:11:07 +00:00
|
|
|
|
base.FromDatabaseAttributes(values);
|
2021-11-15 07:06:46 +00:00
|
|
|
|
|
2021-12-17 20:39:03 +00:00
|
|
|
|
AimDifficulty = values[ATTRIB_ID_AIM];
|
|
|
|
|
SpeedDifficulty = values[ATTRIB_ID_SPEED];
|
2021-11-17 11:31:18 +00:00
|
|
|
|
OverallDifficulty = values[ATTRIB_ID_OVERALL_DIFFICULTY];
|
|
|
|
|
ApproachRate = values[ATTRIB_ID_APPROACH_RATE];
|
|
|
|
|
MaxCombo = (int)values[ATTRIB_ID_MAX_COMBO];
|
2021-12-17 20:39:03 +00:00
|
|
|
|
StarRating = values[ATTRIB_ID_DIFFICULTY];
|
|
|
|
|
FlashlightDifficulty = values.GetValueOrDefault(ATTRIB_ID_FLASHLIGHT);
|
2021-11-17 11:31:18 +00:00
|
|
|
|
SliderFactor = values[ATTRIB_ID_SLIDER_FACTOR];
|
2021-11-15 07:06:46 +00:00
|
|
|
|
}
|
2021-11-15 08:24:53 +00:00
|
|
|
|
|
2021-12-28 07:37:16 +00: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 08:24:53 +00:00
|
|
|
|
[UsedImplicitly]
|
2021-11-17 11:23:08 +00:00
|
|
|
|
public bool ShouldSerializeFlashlightRating() => Mods.Any(m => m is ModFlashlight);
|
2021-12-28 07:37:16 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
2018-06-14 06:36:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|