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-06 07:20:17 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using NUnit.Framework;
|
2018-06-14 07:04:48 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2018-06-06 07:20:17 +00:00
|
|
|
|
using osu.Game.Rulesets.Difficulty;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.NonVisual
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class DifficultyAdjustmentModCombinationsTest
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestNoMods()
|
|
|
|
|
{
|
2019-02-12 07:01:25 +00:00
|
|
|
|
var combinations = new TestLegacyDifficultyCalculator().CreateDifficultyAdjustmentModCombinations();
|
2018-06-06 07:20:17 +00:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(1, combinations.Length);
|
2018-11-30 08:35:13 +00:00
|
|
|
|
Assert.IsTrue(combinations[0] is ModNoMod);
|
2018-06-06 07:20:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestSingleMod()
|
|
|
|
|
{
|
2019-02-12 07:01:25 +00:00
|
|
|
|
var combinations = new TestLegacyDifficultyCalculator(new ModA()).CreateDifficultyAdjustmentModCombinations();
|
2018-06-06 07:20:17 +00:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(2, combinations.Length);
|
2018-11-30 08:35:13 +00:00
|
|
|
|
Assert.IsTrue(combinations[0] is ModNoMod);
|
2018-06-06 07:20:17 +00:00
|
|
|
|
Assert.IsTrue(combinations[1] is ModA);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDoubleMod()
|
|
|
|
|
{
|
2019-02-12 07:01:25 +00:00
|
|
|
|
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModB()).CreateDifficultyAdjustmentModCombinations();
|
2018-06-06 07:20:17 +00:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(4, combinations.Length);
|
2018-11-30 08:35:13 +00:00
|
|
|
|
Assert.IsTrue(combinations[0] is ModNoMod);
|
2018-06-06 07:20:17 +00:00
|
|
|
|
Assert.IsTrue(combinations[1] is ModA);
|
|
|
|
|
Assert.IsTrue(combinations[2] is MultiMod);
|
|
|
|
|
Assert.IsTrue(combinations[3] is ModB);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(((MultiMod)combinations[2]).Mods[0] is ModA);
|
|
|
|
|
Assert.IsTrue(((MultiMod)combinations[2]).Mods[1] is ModB);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestIncompatibleMods()
|
|
|
|
|
{
|
2019-02-12 07:01:25 +00:00
|
|
|
|
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModIncompatibleWithA()).CreateDifficultyAdjustmentModCombinations();
|
2018-06-06 07:20:17 +00:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(3, combinations.Length);
|
2018-11-30 08:35:13 +00:00
|
|
|
|
Assert.IsTrue(combinations[0] is ModNoMod);
|
2018-06-06 07:20:17 +00:00
|
|
|
|
Assert.IsTrue(combinations[1] is ModA);
|
|
|
|
|
Assert.IsTrue(combinations[2] is ModIncompatibleWithA);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDoubleIncompatibleMods()
|
|
|
|
|
{
|
2019-02-12 07:01:25 +00:00
|
|
|
|
var combinations = new TestLegacyDifficultyCalculator(new ModA(), new ModB(), new ModIncompatibleWithA(), new ModIncompatibleWithAAndB()).CreateDifficultyAdjustmentModCombinations();
|
2018-06-06 07:20:17 +00:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(8, combinations.Length);
|
2018-11-30 08:35:13 +00:00
|
|
|
|
Assert.IsTrue(combinations[0] is ModNoMod);
|
2018-06-06 07:20:17 +00:00
|
|
|
|
Assert.IsTrue(combinations[1] is ModA);
|
|
|
|
|
Assert.IsTrue(combinations[2] is MultiMod);
|
|
|
|
|
Assert.IsTrue(combinations[3] is ModB);
|
|
|
|
|
Assert.IsTrue(combinations[4] is MultiMod);
|
|
|
|
|
Assert.IsTrue(combinations[5] is ModIncompatibleWithA);
|
|
|
|
|
Assert.IsTrue(combinations[6] is MultiMod);
|
|
|
|
|
Assert.IsTrue(combinations[7] is ModIncompatibleWithAAndB);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(((MultiMod)combinations[2]).Mods[0] is ModA);
|
|
|
|
|
Assert.IsTrue(((MultiMod)combinations[2]).Mods[1] is ModB);
|
|
|
|
|
Assert.IsTrue(((MultiMod)combinations[4]).Mods[0] is ModB);
|
|
|
|
|
Assert.IsTrue(((MultiMod)combinations[4]).Mods[1] is ModIncompatibleWithA);
|
|
|
|
|
Assert.IsTrue(((MultiMod)combinations[6]).Mods[0] is ModIncompatibleWithA);
|
|
|
|
|
Assert.IsTrue(((MultiMod)combinations[6]).Mods[1] is ModIncompatibleWithAAndB);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestIncompatibleThroughBaseType()
|
|
|
|
|
{
|
2019-02-12 07:01:25 +00:00
|
|
|
|
var combinations = new TestLegacyDifficultyCalculator(new ModAofA(), new ModIncompatibleWithAofA()).CreateDifficultyAdjustmentModCombinations();
|
2018-06-06 07:20:17 +00:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(3, combinations.Length);
|
2018-11-30 08:35:13 +00:00
|
|
|
|
Assert.IsTrue(combinations[0] is ModNoMod);
|
2018-06-06 07:20:17 +00:00
|
|
|
|
Assert.IsTrue(combinations[1] is ModAofA);
|
|
|
|
|
Assert.IsTrue(combinations[2] is ModIncompatibleWithAofA);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class ModA : Mod
|
|
|
|
|
{
|
|
|
|
|
public override string Name => nameof(ModA);
|
2018-11-30 08:16:00 +00:00
|
|
|
|
public override string Acronym => nameof(ModA);
|
2018-06-06 07:20:17 +00:00
|
|
|
|
public override double ScoreMultiplier => 1;
|
|
|
|
|
|
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(ModIncompatibleWithA), typeof(ModIncompatibleWithAAndB) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class ModB : Mod
|
|
|
|
|
{
|
|
|
|
|
public override string Name => nameof(ModB);
|
2018-11-30 08:16:00 +00:00
|
|
|
|
public override string Acronym => nameof(ModB);
|
2018-06-06 07:20:17 +00:00
|
|
|
|
public override double ScoreMultiplier => 1;
|
|
|
|
|
|
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(ModIncompatibleWithAAndB) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class ModIncompatibleWithA : Mod
|
|
|
|
|
{
|
|
|
|
|
public override string Name => $"Incompatible With {nameof(ModA)}";
|
2018-11-30 08:16:00 +00:00
|
|
|
|
public override string Acronym => $"Incompatible With {nameof(ModA)}";
|
2018-06-06 07:20:17 +00:00
|
|
|
|
public override double ScoreMultiplier => 1;
|
|
|
|
|
|
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(ModA) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class ModAofA : ModA
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class ModIncompatibleWithAofA : ModIncompatibleWithA
|
|
|
|
|
{
|
|
|
|
|
// Incompatible through base type
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class ModIncompatibleWithAAndB : Mod
|
|
|
|
|
{
|
|
|
|
|
public override string Name => $"Incompatible With {nameof(ModA)} and {nameof(ModB)}";
|
2018-11-30 08:16:00 +00:00
|
|
|
|
public override string Acronym => $"Incompatible With {nameof(ModA)} and {nameof(ModB)}";
|
2018-06-06 07:20:17 +00:00
|
|
|
|
public override double ScoreMultiplier => 1;
|
|
|
|
|
|
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(ModA), typeof(ModB) };
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-12 07:01:25 +00:00
|
|
|
|
private class TestLegacyDifficultyCalculator : LegacyDifficultyCalculator
|
2018-06-06 07:20:17 +00:00
|
|
|
|
{
|
2019-02-12 07:01:25 +00:00
|
|
|
|
public TestLegacyDifficultyCalculator(params Mod[] mods)
|
2018-06-14 07:04:48 +00:00
|
|
|
|
: base(null, null)
|
2018-06-06 07:20:17 +00:00
|
|
|
|
{
|
|
|
|
|
DifficultyAdjustmentMods = mods;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Mod[] DifficultyAdjustmentMods { get; }
|
2018-06-14 07:04:48 +00:00
|
|
|
|
|
2019-02-19 05:29:23 +00:00
|
|
|
|
protected override DifficultyAttributes Calculate(IBeatmap beatmap, Mod[] mods, double clockRate) => throw new NotImplementedException();
|
2018-06-06 07:20:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|