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;
|
2022-06-27 14:05:49 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
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
|
|
|
|
|
{
|
2022-02-16 13:09:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The difficulty corresponding to the aim skill.
|
|
|
|
|
/// </summary>
|
2021-12-18 04:39:03 +08:00
|
|
|
|
[JsonProperty("aim_difficulty")]
|
|
|
|
|
public double AimDifficulty { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
2022-02-16 13:09:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The difficulty corresponding to the speed skill.
|
|
|
|
|
/// </summary>
|
2021-12-18 04:39:03 +08:00
|
|
|
|
[JsonProperty("speed_difficulty")]
|
|
|
|
|
public double SpeedDifficulty { get; set; }
|
2022-06-20 10:15:35 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The number of clickable objects weighted by difficulty.
|
|
|
|
|
/// Related to <see cref="SpeedDifficulty"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("speed_note_count")]
|
2021-10-11 09:12:57 +08:00
|
|
|
|
public double SpeedNoteCount { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
2022-02-16 13:09:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The difficulty corresponding to the flashlight skill.
|
|
|
|
|
/// </summary>
|
2021-12-18 04:39:03 +08:00
|
|
|
|
[JsonProperty("flashlight_difficulty")]
|
|
|
|
|
public double FlashlightDifficulty { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
2022-02-16 13:09:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Describes how much of <see cref="AimDifficulty"/> is contributed to by hitcircles or sliders.
|
|
|
|
|
/// A value closer to 1.0 indicates most of <see cref="AimDifficulty"/> is contributed by hitcircles.
|
|
|
|
|
/// A value closer to 0.0 indicates most of <see cref="AimDifficulty"/> is contributed by sliders.
|
|
|
|
|
/// </summary>
|
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
|
|
|
|
|
2022-02-16 13:09:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The perceived approach rate inclusive of rate-adjusting mods (DT/HT/etc).
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// Rate-adjusting mods don't directly affect the approach rate difficulty value, but have a perceived effect as a result of adjusting audio timing.
|
|
|
|
|
/// </remarks>
|
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
|
|
|
|
|
2022-02-16 13:09:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The perceived overall difficulty inclusive of rate-adjusting mods (DT/HT/etc).
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// Rate-adjusting mods don't directly affect the overall difficulty value, but have a perceived effect as a result of adjusting audio timing.
|
|
|
|
|
/// </remarks>
|
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
|
|
|
|
|
2022-02-16 13:09:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The beatmap's drain rate. This doesn't scale with rate-adjusting mods.
|
|
|
|
|
/// </summary>
|
2021-09-24 22:02:19 +08:00
|
|
|
|
public double DrainRate { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
2022-02-16 13:09:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The number of hitcircles in the beatmap.
|
|
|
|
|
/// </summary>
|
2021-06-08 17:43:59 +08:00
|
|
|
|
public int HitCircleCount { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
2022-02-16 13:09:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The number of sliders in the beatmap.
|
|
|
|
|
/// </summary>
|
2021-10-14 01:04:34 +08:00
|
|
|
|
public int SliderCount { get; set; }
|
2021-11-15 15:06:29 +08:00
|
|
|
|
|
2022-02-16 13:09:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The number of spinners in the beatmap.
|
|
|
|
|
/// </summary>
|
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);
|
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);
|
2022-06-21 18:31:44 +08:00
|
|
|
|
yield return (ATTRIB_ID_SPEED_NOTE_COUNT, SpeedNoteCount);
|
2021-11-15 15:06:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-27 14:05:49 +08:00
|
|
|
|
public override void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values, IBeatmapOnlineInfo onlineInfo)
|
2021-11-15 15:06:46 +08:00
|
|
|
|
{
|
2022-06-27 14:05:49 +08:00
|
|
|
|
base.FromDatabaseAttributes(values, onlineInfo);
|
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];
|
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];
|
2022-06-21 18:31:44 +08:00
|
|
|
|
SpeedNoteCount = values[ATTRIB_ID_SPEED_NOTE_COUNT];
|
2022-06-27 14:05:49 +08:00
|
|
|
|
|
|
|
|
|
DrainRate = onlineInfo.DrainRate;
|
|
|
|
|
HitCircleCount = onlineInfo.CircleCount;
|
|
|
|
|
SliderCount = onlineInfo.SliderCount;
|
|
|
|
|
SpinnerCount = onlineInfo.SpinnerCount;
|
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
|
|
|
|
}
|
|
|
|
|
}
|