-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25762 from bdach/if-i-speak-i-am-in-big-trouble-pt-2
Fix `GetRateAdjustedDisplayDifficulty()` (partially incorrectly) locally reimplementing difficulty range calculations
- Loading branch information
Showing
11 changed files
with
235 additions
and
28 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
osu.Game.Rulesets.Catch.Tests/CatchRateAdjustedDisplayDifficultyTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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. | ||
|
||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
using osu.Game.Beatmaps; | ||
|
||
namespace osu.Game.Rulesets.Catch.Tests | ||
{ | ||
[TestFixture] | ||
public class CatchRateAdjustedDisplayDifficultyTest | ||
{ | ||
private static IEnumerable<float> difficultyValuesToTest() | ||
{ | ||
for (float i = 0; i <= 10; i += 0.5f) | ||
yield return i; | ||
} | ||
|
||
[TestCaseSource(nameof(difficultyValuesToTest))] | ||
public void TestApproachRateIsUnchangedWithRateEqualToOne(float originalApproachRate) | ||
{ | ||
var ruleset = new CatchRuleset(); | ||
var difficulty = new BeatmapDifficulty { ApproachRate = originalApproachRate }; | ||
|
||
var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1); | ||
|
||
Assert.That(adjustedDifficulty.ApproachRate, Is.EqualTo(originalApproachRate)); | ||
} | ||
|
||
[Test] | ||
public void TestRateBelowOne() | ||
{ | ||
var ruleset = new CatchRuleset(); | ||
var difficulty = new BeatmapDifficulty(); | ||
|
||
var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 0.75); | ||
|
||
Assert.That(adjustedDifficulty.ApproachRate, Is.EqualTo(1.67).Within(0.01)); | ||
} | ||
|
||
[Test] | ||
public void TestRateAboveOne() | ||
{ | ||
var ruleset = new CatchRuleset(); | ||
var difficulty = new BeatmapDifficulty(); | ||
|
||
var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1.5); | ||
|
||
Assert.That(adjustedDifficulty.ApproachRate, Is.EqualTo(7.67).Within(0.01)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
osu.Game.Rulesets.Osu.Tests/OsuRateAdjustedDisplayDifficultyTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// 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. | ||
|
||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
using osu.Game.Beatmaps; | ||
|
||
namespace osu.Game.Rulesets.Osu.Tests | ||
{ | ||
[TestFixture] | ||
public class OsuRateAdjustedDisplayDifficultyTest | ||
{ | ||
private static IEnumerable<float> difficultyValuesToTest() | ||
{ | ||
for (float i = 0; i <= 10; i += 0.5f) | ||
yield return i; | ||
} | ||
|
||
[TestCaseSource(nameof(difficultyValuesToTest))] | ||
public void TestApproachRateIsUnchangedWithRateEqualToOne(float originalApproachRate) | ||
{ | ||
var ruleset = new OsuRuleset(); | ||
var difficulty = new BeatmapDifficulty { ApproachRate = originalApproachRate }; | ||
|
||
var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1); | ||
|
||
Assert.That(adjustedDifficulty.ApproachRate, Is.EqualTo(originalApproachRate)); | ||
} | ||
|
||
[TestCaseSource(nameof(difficultyValuesToTest))] | ||
public void TestOverallDifficultyIsUnchangedWithRateEqualToOne(float originalOverallDifficulty) | ||
{ | ||
var ruleset = new OsuRuleset(); | ||
var difficulty = new BeatmapDifficulty { OverallDifficulty = originalOverallDifficulty }; | ||
|
||
var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1); | ||
|
||
Assert.That(adjustedDifficulty.OverallDifficulty, Is.EqualTo(originalOverallDifficulty)); | ||
} | ||
|
||
[Test] | ||
public void TestRateBelowOne() | ||
{ | ||
var ruleset = new OsuRuleset(); | ||
var difficulty = new BeatmapDifficulty(); | ||
|
||
var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 0.75); | ||
|
||
Assert.That(adjustedDifficulty.ApproachRate, Is.EqualTo(1.67).Within(0.01)); | ||
Assert.That(adjustedDifficulty.OverallDifficulty, Is.EqualTo(2.22).Within(0.01)); | ||
} | ||
|
||
[Test] | ||
public void TestRateAboveOne() | ||
{ | ||
var ruleset = new OsuRuleset(); | ||
var difficulty = new BeatmapDifficulty(); | ||
|
||
var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1.5); | ||
|
||
Assert.That(adjustedDifficulty.ApproachRate, Is.EqualTo(7.67).Within(0.01)); | ||
Assert.That(adjustedDifficulty.OverallDifficulty, Is.EqualTo(7.77).Within(0.01)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
osu.Game.Rulesets.Taiko.Tests/TaikoRateAdjustedDisplayDifficultyTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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. | ||
|
||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
using osu.Game.Beatmaps; | ||
|
||
namespace osu.Game.Rulesets.Taiko.Tests | ||
{ | ||
[TestFixture] | ||
public class TaikoRateAdjustedDisplayDifficultyTest | ||
{ | ||
private static IEnumerable<float> difficultyValuesToTest() | ||
{ | ||
for (float i = 0; i <= 10; i += 0.5f) | ||
yield return i; | ||
} | ||
|
||
[TestCaseSource(nameof(difficultyValuesToTest))] | ||
public void TestOverallDifficultyIsUnchangedWithRateEqualToOne(float originalOverallDifficulty) | ||
{ | ||
var ruleset = new TaikoRuleset(); | ||
var difficulty = new BeatmapDifficulty { OverallDifficulty = originalOverallDifficulty }; | ||
|
||
var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1); | ||
|
||
Assert.That(adjustedDifficulty.OverallDifficulty, Is.EqualTo(originalOverallDifficulty)); | ||
} | ||
|
||
[Test] | ||
public void TestRateBelowOne() | ||
{ | ||
var ruleset = new TaikoRuleset(); | ||
var difficulty = new BeatmapDifficulty(); | ||
|
||
var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 0.75); | ||
|
||
Assert.That(adjustedDifficulty.OverallDifficulty, Is.EqualTo(1.11).Within(0.01)); | ||
} | ||
|
||
[Test] | ||
public void TestRateAboveOne() | ||
{ | ||
var ruleset = new TaikoRuleset(); | ||
var difficulty = new BeatmapDifficulty(); | ||
|
||
var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1.5); | ||
|
||
Assert.That(adjustedDifficulty.OverallDifficulty, Is.EqualTo(8.89).Within(0.01)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters