From d507b76f41b83e5de7bd380911a065cf5ea959af Mon Sep 17 00:00:00 2001 From: Will Wroble Date: Mon, 14 Apr 2025 12:55:11 -0400 Subject: [PATCH] Fixed Plaza of Heroes conditional mana bug I was running AI sims with a deck with Plaza of Heroes and on turn 1 with just this land GetPlayables() thought it could cast sleep cursed faerie and would get stuck in an infinte loop trying to cast it. This happens because the conditional mana gets added to regular mana in addMana(List abilities, Game game). so I changed the logic to use addMana(Mana addMana) which handles conditional mana correctly. --- .../java/mage/abilities/mana/ManaOptions.java | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/mana/ManaOptions.java b/Mage/src/main/java/mage/abilities/mana/ManaOptions.java index 02a214d1d55..1f0a0acc920 100644 --- a/Mage/src/main/java/mage/abilities/mana/ManaOptions.java +++ b/Mage/src/main/java/mage/abilities/mana/ManaOptions.java @@ -3,6 +3,7 @@ package mage.abilities.mana; import mage.ConditionalMana; import mage.Mana; import mage.abilities.Ability; +import mage.abilities.condition.Condition; import mage.constants.ManaType; import mage.game.Game; import mage.game.events.GameEvent; @@ -61,34 +62,20 @@ public class ManaOptions extends LinkedHashSet { } else { // mana source has more than 1 ability //perform a union of all existing options and the new options - List copy = new ArrayList<>(this); - this.clear(); + ManaOptions out = new ManaOptions(); for (ActivatedManaAbilityImpl ability : abilities) { for (Mana netMana : ability.getNetMana(game)) { checkManaReplacementAndTriggeredMana(ability, game, netMana); for (Mana triggeredManaVariation : getTriggeredManaVariations(game, ability, netMana)) { - SkipAddMana: - for (Mana mana : copy) { - Mana newMana = new Mana(); - newMana.add(mana); - newMana.add(triggeredManaVariation); - for (Mana existingMana : this) { - if (existingMana.equalManaValue(newMana)) { - continue SkipAddMana; - } - Mana moreValuable = Mana.getMoreValuableMana(newMana, existingMana); - if (moreValuable != null) { - // only keep the more valuable mana - existingMana.setToMana(moreValuable); - continue SkipAddMana; - } - } - this.add(newMana); - } + ManaOptions copy = new ManaOptions(this); + copy.addMana(triggeredManaVariation); + out.addAll(copy); } - } } + out.removeFullyIncludedVariations(); + this.clear(); + this.addAll(out); } } @@ -348,7 +335,6 @@ public class ManaOptions extends LinkedHashSet { } } } - public void addMana(ManaOptions options) { if (isEmpty()) { this.add(new Mana()); @@ -693,4 +679,4 @@ final class Comparators { private Comparators() { } -} \ No newline at end of file +}