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;
|
2022-06-27 06:05:49 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
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
|
|
|
|
|
{
|
2022-02-16 05:09:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The difficulty corresponding to the aim skill.
|
|
|
|
|
/// </summary>
|
2021-12-17 20:39:03 +00:00
|
|
|
|
[JsonProperty("aim_difficulty")]
|
|
|
|
|
public double AimDifficulty { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
2022-02-16 05:09:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The difficulty corresponding to the speed skill.
|
|
|
|
|
/// </summary>
|
2021-12-17 20:39:03 +00:00
|
|
|
|
[JsonProperty("speed_difficulty")]
|
|
|
|
|
public double SpeedDifficulty { get; set; }
|
2022-06-20 02:15:35 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The number of clickable objects weighted by difficulty.
|
|
|
|
|
/// Related to <see cref="SpeedDifficulty"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty("speed_note_count")]
|
2021-10-11 01:12:57 +00:00
|
|
|
|
public double SpeedNoteCount { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
2022-02-16 05:09:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The difficulty corresponding to the flashlight skill.
|
|
|
|
|
/// </summary>
|
2021-12-17 20:39:03 +00:00
|
|
|
|
[JsonProperty("flashlight_difficulty")]
|
|
|
|
|
public double FlashlightDifficulty { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
2022-02-16 05:09:19 +00: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 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
|
|
|
|
|
2022-02-16 05:09:19 +00: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 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
|
|
|
|
|
2022-02-16 05:09:19 +00: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 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
|
|
|
|
|
2022-02-16 05:09:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The beatmap's drain rate. This doesn't scale with rate-adjusting mods.
|
|
|
|
|
/// </summary>
|
2021-09-24 14:02:19 +00:00
|
|
|
|
public double DrainRate { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
2022-02-16 05:09:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The number of hitcircles in the beatmap.
|
|
|
|
|
/// </summary>
|
2021-06-08 09:43:59 +00:00
|
|
|
|
public int HitCircleCount { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
2022-02-16 05:09:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The number of sliders in the beatmap.
|
|
|
|
|
/// </summary>
|
2021-10-13 17:04:34 +00:00
|
|
|
|
public int SliderCount { get; set; }
|
2021-11-15 07:06:29 +00:00
|
|
|
|
|
2022-02-16 05:09:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The number of spinners in the beatmap.
|
|
|
|
|
/// </summary>
|
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);
|
2022-06-21 10:31:44 +00:00
|
|
|
|
yield return (ATTRIB_ID_SPEED_NOTE_COUNT, SpeedNoteCount);
|
2021-11-15 07:06:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-27 06:05:49 +00:00
|
|
|
|
public override void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values, IBeatmapOnlineInfo onlineInfo)
|
2021-11-15 07:06:46 +00:00
|
|
|
|
{
|
2022-06-27 06:05:49 +00:00
|
|
|
|
base.FromDatabaseAttributes(values, onlineInfo);
|
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];
|
2022-06-21 10:31:44 +00:00
|
|
|
|
SpeedNoteCount = values[ATTRIB_ID_SPEED_NOTE_COUNT];
|
2022-06-27 06:05:49 +00:00
|
|
|
|
|
|
|
|
|
DrainRate = onlineInfo.DrainRate;
|
|
|
|
|
HitCircleCount = onlineInfo.CircleCount;
|
|
|
|
|
SliderCount = onlineInfo.SliderCount;
|
|
|
|
|
SpinnerCount = onlineInfo.SpinnerCount;
|
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
|
|
|
|
}
|
|
|
|
|
}
|