From d2b4963f338c69afca7aa07a6c5c8234b7e0907a Mon Sep 17 00:00:00 2001 From: chillu Date: Mon, 24 Jun 2024 22:09:11 +0200 Subject: [PATCH] fix: remove on stacks --- ModiBuff/ModiBuff.Tests/SaveLoadRecipeTests.cs | 1 + ModiBuff/ModiBuff.Tests/StackTests.cs | 16 ++++++++++++++++ .../Modifier/Creation/Recipe/ModifierRecipe.cs | 5 ----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ModiBuff/ModiBuff.Tests/SaveLoadRecipeTests.cs b/ModiBuff/ModiBuff.Tests/SaveLoadRecipeTests.cs index 3e8ecf6..10c2866 100644 --- a/ModiBuff/ModiBuff.Tests/SaveLoadRecipeTests.cs +++ b/ModiBuff/ModiBuff.Tests/SaveLoadRecipeTests.cs @@ -196,6 +196,7 @@ public void SaveRemoveStackRecipeLoad() Unit.AddModifierSelf("RemoveStack"); Assert.True(Unit.ContainsModifier("RemoveStack")); Unit.AddModifierSelf("RemoveStack"); + Unit.Update(0); Assert.False(Unit.ContainsModifier("RemoveStack")); } diff --git a/ModiBuff/ModiBuff.Tests/StackTests.cs b/ModiBuff/ModiBuff.Tests/StackTests.cs index 6146e62..8c15668 100644 --- a/ModiBuff/ModiBuff.Tests/StackTests.cs +++ b/ModiBuff/ModiBuff.Tests/StackTests.cs @@ -291,6 +291,22 @@ public void RemoveOnMaxStacks() Unit.AddModifierSelf("RemoveStack"); Assert.True(Unit.ContainsModifier("RemoveStack")); Unit.AddModifierSelf("RemoveStack"); + Unit.Update(0); + Assert.False(Unit.ContainsModifier("RemoveStack")); + } + + [Test] + public void RemoveOnMaxStacksEffect() + { + AddRecipe("RemoveStack") + .Effect(new RemoveEffect(), EffectOn.Stack) + .Stack(WhenStackEffect.OnMaxStacks, 2); + Setup(); + + Unit.AddModifierSelf("RemoveStack"); + Assert.True(Unit.ContainsModifier("RemoveStack")); + Unit.AddModifierSelf("RemoveStack"); + Unit.Update(0); Assert.False(Unit.ContainsModifier("RemoveStack")); } } diff --git a/ModiBuff/ModiBuff/Core/Modifier/Creation/Recipe/ModifierRecipe.cs b/ModiBuff/ModiBuff/Core/Modifier/Creation/Recipe/ModifierRecipe.cs index e5cc9d5..5e36f17 100644 --- a/ModiBuff/ModiBuff/Core/Modifier/Creation/Recipe/ModifierRecipe.cs +++ b/ModiBuff/ModiBuff/Core/Modifier/Creation/Recipe/ModifierRecipe.cs @@ -382,11 +382,6 @@ public ModifierRecipe Effect(IEffect effect, EffectOn effectOn) #if DEBUG && !MODIBUFF_PROFILE Logger.LogWarning("[ModiBuff] Adding a remove effect through Effect() is not recommended, " + "use Remove(RemoveEffectOn) or Remove(float) instead"); - if (effectOn.HasFlag(EffectOn.Stack)) - { - Logger.LogError("[ModiBuff] Adding a remove effect through stack is not currently supported"); - effectOn &= ~EffectOn.Stack; - } #endif AddRemoveEffect(effectOn); _saveInstructions.Add(new SaveInstruction.Remove(SaveInstruction.Remove.Type.RemoveOn, effectOn));