From 815179f713dd2d1f7b636ebdd0bf387d821fbd35 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 17 Nov 2021 20:31:18 +0900 Subject: [PATCH] Use consts for attribute IDs --- .../Difficulty/CatchDifficultyAttributes.cs | 14 ++++---- .../Difficulty/ManiaDifficultyAttributes.cs | 14 ++++---- .../Difficulty/OsuDifficultyAttributes.cs | 32 +++++++++---------- .../Difficulty/TaikoDifficultyAttributes.cs | 12 +++---- .../Difficulty/DifficultyAttributes.cs | 11 +++++++ 5 files changed, 47 insertions(+), 36 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs index ca63e87f8d..39a58d336d 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs @@ -17,19 +17,19 @@ namespace osu.Game.Rulesets.Catch.Difficulty foreach (var v in base.ToDatabaseAttributes()) yield return v; - // Todo: Catch should not output star rating in the 'aim' attribute. - yield return (1, StarRating); - yield return (7, ApproachRate); - yield return (9, MaxCombo); + // Todo: osu!catch should not output star rating in the 'aim' attribute. + yield return (ATTRIB_ID_AIM, StarRating); + yield return (ATTRIB_ID_APPROACH_RATE, ApproachRate); + yield return (ATTRIB_ID_MAX_COMBO, MaxCombo); } public override void FromDatabaseAttributes(IReadOnlyDictionary values) { base.FromDatabaseAttributes(values); - StarRating = values[1]; - ApproachRate = values[7]; - MaxCombo = (int)values[9]; + StarRating = values[ATTRIB_ID_AIM]; + ApproachRate = values[ATTRIB_ID_APPROACH_RATE]; + MaxCombo = (int)values[ATTRIB_ID_MAX_COMBO]; } } } diff --git a/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyAttributes.cs b/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyAttributes.cs index 1e663fe103..bfdef893e9 100644 --- a/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyAttributes.cs +++ b/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyAttributes.cs @@ -20,19 +20,19 @@ namespace osu.Game.Rulesets.Mania.Difficulty foreach (var v in base.ToDatabaseAttributes()) yield return v; - // Todo: Mania doesn't output MaxCombo attribute for some reason. - yield return (11, StarRating); - yield return (13, GreatHitWindow); - yield return (15, ScoreMultiplier); + // Todo: osu!mania doesn't output MaxCombo attribute for some reason. + yield return (ATTRIB_ID_STRAIN, StarRating); + yield return (ATTRIB_ID_GREAT_HIT_WINDOW, GreatHitWindow); + yield return (ATTRIB_ID_SCORE_MULTIPLIER, ScoreMultiplier); } public override void FromDatabaseAttributes(IReadOnlyDictionary values) { base.FromDatabaseAttributes(values); - StarRating = values[11]; - GreatHitWindow = values[13]; - ScoreMultiplier = values[15]; + StarRating = values[ATTRIB_ID_STRAIN]; + GreatHitWindow = values[ATTRIB_ID_GREAT_HIT_WINDOW]; + ScoreMultiplier = values[ATTRIB_ID_SCORE_MULTIPLIER]; } } } diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyAttributes.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyAttributes.cs index a22b605176..4b2e54da17 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyAttributes.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyAttributes.cs @@ -43,31 +43,31 @@ namespace osu.Game.Rulesets.Osu.Difficulty foreach (var v in base.ToDatabaseAttributes()) yield return v; - yield return (1, AimStrain); - yield return (3, SpeedStrain); - yield return (5, OverallDifficulty); - yield return (7, ApproachRate); - yield return (9, MaxCombo); - yield return (11, StarRating); + yield return (ATTRIB_ID_AIM, AimStrain); + yield return (ATTRIB_ID_SPEED, SpeedStrain); + yield return (ATTRIB_ID_OVERALL_DIFFICULTY, OverallDifficulty); + yield return (ATTRIB_ID_APPROACH_RATE, ApproachRate); + yield return (ATTRIB_ID_MAX_COMBO, MaxCombo); + yield return (ATTRIB_ID_STRAIN, StarRating); if (ShouldSerializeFlashlightRating()) - yield return (17, FlashlightRating); + yield return (ATTRIB_ID_FLASHLIGHT, FlashlightRating); - yield return (19, SliderFactor); + yield return (ATTRIB_ID_SLIDER_FACTOR, SliderFactor); } public override void FromDatabaseAttributes(IReadOnlyDictionary values) { base.FromDatabaseAttributes(values); - AimStrain = values[1]; - SpeedStrain = values[3]; - OverallDifficulty = values[5]; - ApproachRate = values[7]; - MaxCombo = (int)values[9]; - StarRating = values[11]; - FlashlightRating = values.GetValueOrDefault(17); - SliderFactor = values[19]; + AimStrain = values[ATTRIB_ID_AIM]; + SpeedStrain = values[ATTRIB_ID_SPEED]; + OverallDifficulty = values[ATTRIB_ID_OVERALL_DIFFICULTY]; + ApproachRate = values[ATTRIB_ID_APPROACH_RATE]; + MaxCombo = (int)values[ATTRIB_ID_MAX_COMBO]; + StarRating = values[ATTRIB_ID_STRAIN]; + FlashlightRating = values.GetValueOrDefault(ATTRIB_ID_FLASHLIGHT); + SliderFactor = values[ATTRIB_ID_SLIDER_FACTOR]; } // Used implicitly by Newtonsoft.Json to not serialize flashlight property in some cases. diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyAttributes.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyAttributes.cs index a6057d7952..b2b5d056c3 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyAttributes.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyAttributes.cs @@ -29,18 +29,18 @@ namespace osu.Game.Rulesets.Taiko.Difficulty foreach (var v in base.ToDatabaseAttributes()) yield return v; - yield return (9, MaxCombo); - yield return (11, StarRating); - yield return (13, GreatHitWindow); + yield return (ATTRIB_ID_MAX_COMBO, MaxCombo); + yield return (ATTRIB_ID_STRAIN, StarRating); + yield return (ATTRIB_ID_GREAT_HIT_WINDOW, GreatHitWindow); } public override void FromDatabaseAttributes(IReadOnlyDictionary values) { base.FromDatabaseAttributes(values); - MaxCombo = (int)values[9]; - StarRating = values[11]; - GreatHitWindow = values[13]; + MaxCombo = (int)values[ATTRIB_ID_MAX_COMBO]; + StarRating = values[ATTRIB_ID_STRAIN]; + GreatHitWindow = values[ATTRIB_ID_GREAT_HIT_WINDOW]; } } } diff --git a/osu.Game/Rulesets/Difficulty/DifficultyAttributes.cs b/osu.Game/Rulesets/Difficulty/DifficultyAttributes.cs index 1073f689dd..320321440a 100644 --- a/osu.Game/Rulesets/Difficulty/DifficultyAttributes.cs +++ b/osu.Game/Rulesets/Difficulty/DifficultyAttributes.cs @@ -72,5 +72,16 @@ namespace osu.Game.Rulesets.Difficulty public virtual void FromDatabaseAttributes(IReadOnlyDictionary values) { } + + protected const int ATTRIB_ID_AIM = 1; + protected const int ATTRIB_ID_SPEED = 3; + protected const int ATTRIB_ID_OVERALL_DIFFICULTY = 5; + protected const int ATTRIB_ID_APPROACH_RATE = 7; + protected const int ATTRIB_ID_MAX_COMBO = 9; + protected const int ATTRIB_ID_STRAIN = 11; + protected const int ATTRIB_ID_GREAT_HIT_WINDOW = 13; + protected const int ATTRIB_ID_SCORE_MULTIPLIER = 15; + protected const int ATTRIB_ID_FLASHLIGHT = 17; + protected const int ATTRIB_ID_SLIDER_FACTOR = 19; } }