mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 02:32:55 +08:00
Merge pull request #17714 from bdach/mod-overlay/multimod-incompatibility
Ensure that mods grouped into multi mods are pairwise incompatible
This commit is contained in:
commit
c48f8d7b9b
@ -29,6 +29,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
public override ModType Type => ModType.DifficultyIncrease;
|
public override ModType Type => ModType.DifficultyIncrease;
|
||||||
|
|
||||||
public override double ScoreMultiplier => 1.12;
|
public override double ScoreMultiplier => 1.12;
|
||||||
|
public override Type[] IncompatibleMods => new[] { typeof(OsuModFlashlight) };
|
||||||
|
|
||||||
private DrawableOsuBlinds blinds;
|
private DrawableOsuBlinds blinds;
|
||||||
|
|
||||||
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// 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;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
@ -19,6 +20,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
public class OsuModFlashlight : ModFlashlight<OsuHitObject>, IApplicableToDrawableHitObject
|
public class OsuModFlashlight : ModFlashlight<OsuHitObject>, IApplicableToDrawableHitObject
|
||||||
{
|
{
|
||||||
public override double ScoreMultiplier => 1.12;
|
public override double ScoreMultiplier => 1.12;
|
||||||
|
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModBlinds)).ToArray();
|
||||||
|
|
||||||
private const double default_follow_delay = 120;
|
private const double default_follow_delay = 120;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
protected virtual float EndScale => 1;
|
protected virtual float EndScale => 1;
|
||||||
|
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(IRequiresApproachCircles), typeof(OsuModSpinIn) };
|
public override Type[] IncompatibleMods => new[] { typeof(IRequiresApproachCircles), typeof(OsuModSpinIn), typeof(OsuModObjectScaleTween) };
|
||||||
|
|
||||||
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||||
{
|
{
|
||||||
|
65
osu.Game.Tests/Mods/MultiModIncompatibilityTest.cs
Normal file
65
osu.Game.Tests/Mods/MultiModIncompatibilityTest.cs
Normal file
@ -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;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Catch;
|
||||||
|
using osu.Game.Rulesets.Mania;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Rulesets.Taiko;
|
||||||
|
using osu.Game.Utils;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Mods
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class MultiModIncompatibilityTest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Ensures that all mods grouped into <see cref="MultiMod"/>s, as declared by the default rulesets, are pairwise incompatible with each other.
|
||||||
|
/// </summary>
|
||||||
|
[TestCase(typeof(OsuRuleset))]
|
||||||
|
[TestCase(typeof(TaikoRuleset))]
|
||||||
|
[TestCase(typeof(CatchRuleset))]
|
||||||
|
[TestCase(typeof(ManiaRuleset))]
|
||||||
|
public void TestAllMultiModsFromRulesetAreIncompatible(Type rulesetType)
|
||||||
|
{
|
||||||
|
var ruleset = (Ruleset)Activator.CreateInstance(rulesetType);
|
||||||
|
Assert.That(ruleset, Is.Not.Null);
|
||||||
|
|
||||||
|
var allMultiMods = getMultiMods(ruleset);
|
||||||
|
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
foreach (var multiMod in allMultiMods)
|
||||||
|
{
|
||||||
|
int modCount = multiMod.Mods.Length;
|
||||||
|
|
||||||
|
for (int i = 0; i < modCount; ++i)
|
||||||
|
{
|
||||||
|
// indexing from i + 1 ensures that only pairs of different mods are checked, and are checked only once
|
||||||
|
// (indexing from 0 would check each pair twice, and also check each mod against itself).
|
||||||
|
for (int j = i + 1; j < modCount; ++j)
|
||||||
|
{
|
||||||
|
var firstMod = multiMod.Mods[i];
|
||||||
|
var secondMod = multiMod.Mods[j];
|
||||||
|
|
||||||
|
Assert.That(
|
||||||
|
ModUtils.CheckCompatibleSet(new[] { firstMod, secondMod }), Is.False,
|
||||||
|
$"{firstMod.Name} ({firstMod.Acronym}) and {secondMod.Name} ({secondMod.Acronym}) should be incompatible.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <remarks>
|
||||||
|
/// This local helper is used rather than <see cref="Ruleset.CreateAllMods"/>, because the aforementioned method flattens multi mods.
|
||||||
|
/// </remarks>>
|
||||||
|
private static IEnumerable<MultiMod> getMultiMods(Ruleset ruleset)
|
||||||
|
=> Enum.GetValues(typeof(ModType)).Cast<ModType>().SelectMany(ruleset.GetModsFor).OfType<MultiMod>();
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +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.Linq;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
@ -18,8 +16,6 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
public override ModType Type => ModType.DifficultyIncrease;
|
public override ModType Type => ModType.DifficultyIncrease;
|
||||||
public override string Description => "Zoooooooooom...";
|
public override string Description => "Zoooooooooom...";
|
||||||
|
|
||||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModHalfTime)).ToArray();
|
|
||||||
|
|
||||||
[SettingSource("Speed increase", "The actual increase to apply")]
|
[SettingSource("Speed increase", "The actual increase to apply")]
|
||||||
public override BindableNumber<double> SpeedChange { get; } = new BindableDouble
|
public override BindableNumber<double> SpeedChange { get; } = new BindableDouble
|
||||||
{
|
{
|
||||||
|
@ -1,8 +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.Linq;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
@ -18,8 +16,6 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
public override ModType Type => ModType.DifficultyReduction;
|
public override ModType Type => ModType.DifficultyReduction;
|
||||||
public override string Description => "Less zoom...";
|
public override string Description => "Less zoom...";
|
||||||
|
|
||||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModDoubleTime)).ToArray();
|
|
||||||
|
|
||||||
[SettingSource("Speed decrease", "The actual decrease to apply")]
|
[SettingSource("Speed decrease", "The actual decrease to apply")]
|
||||||
public override BindableNumber<double> SpeedChange { get; } = new BindableDouble
|
public override BindableNumber<double> SpeedChange { get; } = new BindableDouble
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
|
|
||||||
public double ApplyToRate(double time, double rate) => rate * SpeedChange.Value;
|
public double ApplyToRate(double time, double rate) => rate * SpeedChange.Value;
|
||||||
|
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(ModTimeRamp), typeof(ModAdaptiveSpeed) };
|
public override Type[] IncompatibleMods => new[] { typeof(ModTimeRamp), typeof(ModAdaptiveSpeed), typeof(ModRateAdjust) };
|
||||||
|
|
||||||
public override string SettingDescription => SpeedChange.IsDefault ? string.Empty : $"{SpeedChange.Value:N2}x";
|
public override string SettingDescription => SpeedChange.IsDefault ? string.Empty : $"{SpeedChange.Value:N2}x";
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,9 @@ namespace osu.Game.Utils
|
|||||||
{
|
{
|
||||||
mods = mods.ToArray();
|
mods = mods.ToArray();
|
||||||
|
|
||||||
CheckCompatibleSet(mods, out invalidMods);
|
// exclude multi mods from compatibility checks.
|
||||||
|
// the loop below automatically marks all multi mods as not valid for gameplay anyway.
|
||||||
|
CheckCompatibleSet(mods.Where(m => !(m is MultiMod)), out invalidMods);
|
||||||
|
|
||||||
foreach (var mod in mods)
|
foreach (var mod in mods)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user