1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-06 21:02:59 +08:00

Revert "Use fresh mods for each difficulty calculation"

This reverts commit 24fb25f1cd.
This commit is contained in:
smoogipoo 2019-03-23 15:57:22 +09:00
parent 13e480baa0
commit 839dd7343f
6 changed files with 42 additions and 46 deletions

View File

@ -91,12 +91,12 @@ namespace osu.Game.Rulesets.Catch.Difficulty
new Movement(), new Movement(),
}; };
protected override Type[] DifficultyAdjustmentMods => new[] protected override Mod[] DifficultyAdjustmentMods => new Mod[]
{ {
typeof(CatchModDoubleTime), new CatchModDoubleTime(),
typeof(CatchModHalfTime), new CatchModHalfTime(),
typeof(CatchModHardRock), new CatchModHardRock(),
typeof(CatchModEasy), new CatchModEasy(),
}; };
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -92,33 +91,33 @@ namespace osu.Game.Rulesets.Mania.Difficulty
return skills.ToArray(); return skills.ToArray();
} }
protected override Type[] DifficultyAdjustmentMods protected override Mod[] DifficultyAdjustmentMods
{ {
get get
{ {
var mods = new[] var mods = new Mod[]
{ {
typeof(ManiaModDoubleTime), new ManiaModDoubleTime(),
typeof(ManiaModHalfTime), new ManiaModHalfTime(),
typeof(ManiaModEasy), new ManiaModEasy(),
typeof(ManiaModHardRock) new ManiaModHardRock(),
}; };
if (isForCurrentRuleset) if (isForCurrentRuleset)
return mods; return mods;
// if we are a convert, we can be played in any key mod. // if we are a convert, we can be played in any key mod.
return mods.Concat(new[] return mods.Concat(new Mod[]
{ {
typeof(ManiaModKey1), new ManiaModKey1(),
typeof(ManiaModKey2), new ManiaModKey2(),
typeof(ManiaModKey3), new ManiaModKey3(),
typeof(ManiaModKey4), new ManiaModKey4(),
typeof(ManiaModKey5), new ManiaModKey5(),
typeof(ManiaModKey6), new ManiaModKey6(),
typeof(ManiaModKey7), new ManiaModKey7(),
typeof(ManiaModKey8), new ManiaModKey8(),
typeof(ManiaModKey9), new ManiaModKey9(),
}).ToArray(); }).ToArray();
} }
} }

View File

@ -74,12 +74,12 @@ namespace osu.Game.Rulesets.Osu.Difficulty
new Speed() new Speed()
}; };
protected override Type[] DifficultyAdjustmentMods => new[] protected override Mod[] DifficultyAdjustmentMods => new Mod[]
{ {
typeof(OsuModDoubleTime), new OsuModDoubleTime(),
typeof(OsuModHalfTime), new OsuModHalfTime(),
typeof(OsuModEasy), new OsuModEasy(),
typeof(OsuModHardRock), new OsuModHardRock(),
}; };
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -48,12 +47,12 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
protected override Skill[] CreateSkills(IBeatmap beatmap) => new Skill[] { new Strain() }; protected override Skill[] CreateSkills(IBeatmap beatmap) => new Skill[] { new Strain() };
protected override Type[] DifficultyAdjustmentMods => new[] protected override Mod[] DifficultyAdjustmentMods => new Mod[]
{ {
typeof(TaikoModDoubleTime), new TaikoModDoubleTime(),
typeof(TaikoModHalfTime), new TaikoModHalfTime(),
typeof(TaikoModEasy), new TaikoModEasy(),
typeof(TaikoModHardRock), new TaikoModHardRock(),
}; };
} }
} }

View File

@ -27,7 +27,7 @@ namespace osu.Game.Tests.NonVisual
[Test] [Test]
public void TestSingleMod() public void TestSingleMod()
{ {
var combinations = new TestLegacyDifficultyCalculator(typeof(ModA)).CreateDifficultyAdjustmentModCombinations(); var combinations = new TestLegacyDifficultyCalculator(new ModA()).CreateDifficultyAdjustmentModCombinations();
Assert.AreEqual(2, combinations.Length); Assert.AreEqual(2, combinations.Length);
Assert.IsTrue(combinations[0] is ModNoMod); Assert.IsTrue(combinations[0] is ModNoMod);
@ -37,7 +37,7 @@ namespace osu.Game.Tests.NonVisual
[Test] [Test]
public void TestDoubleMod() public void TestDoubleMod()
{ {
var combinations = new TestLegacyDifficultyCalculator(typeof(ModA), typeof(ModB)).CreateDifficultyAdjustmentModCombinations(); var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModB()).CreateDifficultyAdjustmentModCombinations();
Assert.AreEqual(4, combinations.Length); Assert.AreEqual(4, combinations.Length);
Assert.IsTrue(combinations[0] is ModNoMod); Assert.IsTrue(combinations[0] is ModNoMod);
@ -52,7 +52,7 @@ namespace osu.Game.Tests.NonVisual
[Test] [Test]
public void TestIncompatibleMods() public void TestIncompatibleMods()
{ {
var combinations = new TestLegacyDifficultyCalculator(typeof(ModA), typeof(ModIncompatibleWithA)).CreateDifficultyAdjustmentModCombinations(); var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModIncompatibleWithA()).CreateDifficultyAdjustmentModCombinations();
Assert.AreEqual(3, combinations.Length); Assert.AreEqual(3, combinations.Length);
Assert.IsTrue(combinations[0] is ModNoMod); Assert.IsTrue(combinations[0] is ModNoMod);
@ -63,7 +63,7 @@ namespace osu.Game.Tests.NonVisual
[Test] [Test]
public void TestDoubleIncompatibleMods() public void TestDoubleIncompatibleMods()
{ {
var combinations = new TestLegacyDifficultyCalculator(typeof(ModA), typeof(ModB), typeof(ModIncompatibleWithA), typeof(ModIncompatibleWithAAndB)).CreateDifficultyAdjustmentModCombinations(); var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModB(), new ModIncompatibleWithA(), new ModIncompatibleWithAAndB()).CreateDifficultyAdjustmentModCombinations();
Assert.AreEqual(8, combinations.Length); Assert.AreEqual(8, combinations.Length);
Assert.IsTrue(combinations[0] is ModNoMod); Assert.IsTrue(combinations[0] is ModNoMod);
@ -86,7 +86,7 @@ namespace osu.Game.Tests.NonVisual
[Test] [Test]
public void TestIncompatibleThroughBaseType() public void TestIncompatibleThroughBaseType()
{ {
var combinations = new TestLegacyDifficultyCalculator(typeof(ModAofA), typeof(ModIncompatibleWithAofA)).CreateDifficultyAdjustmentModCombinations(); var combinations = new TestLegacyDifficultyCalculator(new ModAofA(), new ModIncompatibleWithAofA()).CreateDifficultyAdjustmentModCombinations();
Assert.AreEqual(3, combinations.Length); Assert.AreEqual(3, combinations.Length);
Assert.IsTrue(combinations[0] is ModNoMod); Assert.IsTrue(combinations[0] is ModNoMod);
@ -141,13 +141,13 @@ namespace osu.Game.Tests.NonVisual
private class TestLegacyDifficultyCalculator : DifficultyCalculator private class TestLegacyDifficultyCalculator : DifficultyCalculator
{ {
public TestLegacyDifficultyCalculator(params Type[] mods) public TestLegacyDifficultyCalculator(params Mod[] mods)
: base(null, null) : base(null, null)
{ {
DifficultyAdjustmentMods = mods; DifficultyAdjustmentMods = mods;
} }
protected override Type[] DifficultyAdjustmentMods { get; } protected override Mod[] DifficultyAdjustmentMods { get; }
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
{ {

View File

@ -108,7 +108,7 @@ namespace osu.Game.Rulesets.Difficulty
{ {
return createDifficultyAdjustmentModCombinations(Enumerable.Empty<Mod>(), DifficultyAdjustmentMods).ToArray(); return createDifficultyAdjustmentModCombinations(Enumerable.Empty<Mod>(), DifficultyAdjustmentMods).ToArray();
IEnumerable<Mod> createDifficultyAdjustmentModCombinations(IEnumerable<Mod> currentSet, Type[] adjustmentSet, int currentSetCount = 0, int adjustmentSetStart = 0) IEnumerable<Mod> createDifficultyAdjustmentModCombinations(IEnumerable<Mod> currentSet, Mod[] adjustmentSet, int currentSetCount = 0, int adjustmentSetStart = 0)
{ {
switch (currentSetCount) switch (currentSetCount)
{ {
@ -131,14 +131,12 @@ namespace osu.Game.Rulesets.Difficulty
// combinations in further recursions, so a moving subset is used to eliminate this effect // combinations in further recursions, so a moving subset is used to eliminate this effect
for (int i = adjustmentSetStart; i < adjustmentSet.Length; i++) for (int i = adjustmentSetStart; i < adjustmentSet.Length; i++)
{ {
var adjustmentMod = createMod(); var adjustmentMod = adjustmentSet[i];
if (currentSet.Any(c => c.IncompatibleMods.Any(m => m.IsInstanceOfType(adjustmentMod)))) if (currentSet.Any(c => c.IncompatibleMods.Any(m => m.IsInstanceOfType(adjustmentMod))))
continue; continue;
foreach (var combo in createDifficultyAdjustmentModCombinations(currentSet.Append(createMod()), adjustmentSet, currentSetCount + 1, i + 1)) foreach (var combo in createDifficultyAdjustmentModCombinations(currentSet.Append(adjustmentMod), adjustmentSet, currentSetCount + 1, i + 1))
yield return combo; yield return combo;
Mod createMod() => (Mod)Activator.CreateInstance(adjustmentSet[i]);
} }
} }
} }
@ -146,7 +144,7 @@ namespace osu.Game.Rulesets.Difficulty
/// <summary> /// <summary>
/// Retrieves all <see cref="Mod"/>s which adjust the <see cref="Beatmap"/> difficulty. /// Retrieves all <see cref="Mod"/>s which adjust the <see cref="Beatmap"/> difficulty.
/// </summary> /// </summary>
protected virtual Type[] DifficultyAdjustmentMods => Array.Empty<Type>(); protected virtual Mod[] DifficultyAdjustmentMods => Array.Empty<Mod>();
/// <summary> /// <summary>
/// Creates <see cref="DifficultyAttributes"/> to describe beatmap's calculated difficulty. /// Creates <see cref="DifficultyAttributes"/> to describe beatmap's calculated difficulty.