1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 12:02:54 +08:00

Merge pull request #18863 from smoogipoo/difficulty-attributes-beatmap

Pass online beatmap info into `DifficultyAttributes.FromDatabaseAttributes()`
This commit is contained in:
Dean Herbert 2022-06-27 17:16:52 +09:00 committed by GitHub
commit 7ae222d984
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 54 additions and 24 deletions

View File

@ -1,10 +1,9 @@
// 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.
#nullable disable
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
namespace osu.Game.Rulesets.Catch.Difficulty
@ -31,9 +30,9 @@ namespace osu.Game.Rulesets.Catch.Difficulty
yield return (ATTRIB_ID_MAX_COMBO, MaxCombo);
}
public override void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values)
public override void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values, IBeatmapOnlineInfo onlineInfo)
{
base.FromDatabaseAttributes(values);
base.FromDatabaseAttributes(values, onlineInfo);
StarRating = values[ATTRIB_ID_AIM];
ApproachRate = values[ATTRIB_ID_APPROACH_RATE];

View File

@ -1,10 +1,9 @@
// 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.
#nullable disable
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
namespace osu.Game.Rulesets.Mania.Difficulty
@ -37,9 +36,9 @@ namespace osu.Game.Rulesets.Mania.Difficulty
yield return (ATTRIB_ID_SCORE_MULTIPLIER, ScoreMultiplier);
}
public override void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values)
public override void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values, IBeatmapOnlineInfo onlineInfo)
{
base.FromDatabaseAttributes(values);
base.FromDatabaseAttributes(values, onlineInfo);
MaxCombo = (int)values[ATTRIB_ID_MAX_COMBO];
StarRating = values[ATTRIB_ID_DIFFICULTY];

View File

@ -1,12 +1,11 @@
// 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.
#nullable disable
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Newtonsoft.Json;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
@ -96,9 +95,9 @@ namespace osu.Game.Rulesets.Osu.Difficulty
yield return (ATTRIB_ID_SLIDER_FACTOR, SliderFactor);
}
public override void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values)
public override void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values, IBeatmapOnlineInfo onlineInfo)
{
base.FromDatabaseAttributes(values);
base.FromDatabaseAttributes(values, onlineInfo);
AimDifficulty = values[ATTRIB_ID_AIM];
SpeedDifficulty = values[ATTRIB_ID_SPEED];
@ -108,6 +107,11 @@ namespace osu.Game.Rulesets.Osu.Difficulty
StarRating = values[ATTRIB_ID_DIFFICULTY];
FlashlightDifficulty = values.GetValueOrDefault(ATTRIB_ID_FLASHLIGHT);
SliderFactor = values[ATTRIB_ID_SLIDER_FACTOR];
DrainRate = onlineInfo.DrainRate;
HitCircleCount = onlineInfo.CircleCount;
SliderCount = onlineInfo.SliderCount;
SpinnerCount = onlineInfo.SpinnerCount;
}
#region Newtonsoft.Json implicit ShouldSerialize() methods

View File

@ -1,10 +1,9 @@
// 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.
#nullable disable
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
namespace osu.Game.Rulesets.Taiko.Difficulty
@ -57,9 +56,9 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
yield return (ATTRIB_ID_GREAT_HIT_WINDOW, GreatHitWindow);
}
public override void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values)
public override void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values, IBeatmapOnlineInfo onlineInfo)
{
base.FromDatabaseAttributes(values);
base.FromDatabaseAttributes(values, onlineInfo);
MaxCombo = (int)values[ATTRIB_ID_MAX_COMBO];
StarRating = values[ATTRIB_ID_DIFFICULTY];

View File

@ -13,25 +13,50 @@ namespace osu.Game.Beatmaps
/// </summary>
int? MaxCombo { get; }
/// <summary>
/// The approach rate.
/// </summary>
float ApproachRate { get; }
/// <summary>
/// The circle size.
/// </summary>
float CircleSize { get; }
/// <summary>
/// The drain rate.
/// </summary>
float DrainRate { get; }
/// <summary>
/// The overall difficulty.
/// </summary>
float OverallDifficulty { get; }
/// <summary>
/// The amount of circles in this beatmap.
/// </summary>
public int CircleCount { get; }
int CircleCount { get; }
/// <summary>
/// The amount of sliders in this beatmap.
/// </summary>
public int SliderCount { get; }
int SliderCount { get; }
/// <summary>
/// The amount of spinners in tihs beatmap.
/// </summary>
int SpinnerCount { get; }
/// <summary>
/// The amount of plays this beatmap has.
/// </summary>
public int PlayCount { get; }
int PlayCount { get; }
/// <summary>
/// The amount of passes this beatmap has.
/// </summary>
public int PassCount { get; }
int PassCount { get; }
APIFailTimes? FailTimes { get; }
}

View File

@ -69,6 +69,9 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"count_sliders")]
public int SliderCount { get; set; }
[JsonProperty(@"count_spinners")]
public int SpinnerCount { get; set; }
[JsonProperty(@"version")]
public string DifficultyName { get; set; } = string.Empty;

View File

@ -1,11 +1,11 @@
// 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.
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.Difficulty
@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Difficulty
/// <summary>
/// The mods which were applied to the beatmap.
/// </summary>
public Mod[] Mods { get; set; }
public Mod[] Mods { get; set; } = Array.Empty<Mod>();
/// <summary>
/// The combined star rating of all skills.
@ -74,7 +74,8 @@ namespace osu.Game.Rulesets.Difficulty
/// Reads osu-web database attribute mappings into this <see cref="DifficultyAttributes"/> object.
/// </summary>
/// <param name="values">The attribute mappings.</param>
public virtual void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values)
/// <param name="onlineInfo">The <see cref="IBeatmapOnlineInfo"/> where more information about the beatmap may be extracted from (such as AR/CS/OD/etc).</param>
public virtual void FromDatabaseAttributes(IReadOnlyDictionary<int, double> values, IBeatmapOnlineInfo onlineInfo)
{
}
}