From b948a8255aa1e7f5fc66878b1634f072934975ff Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 23 Jul 2017 22:49:56 +0200 Subject: [PATCH] * Some cleanup for: Fixed a bug that created a endless loop if mana producer were involved, that create mana of any type lands of players could produce. --- Mage.Sets/src/mage/cards/n/NagaVitalist.java | 2 +- .../src/mage/cards/r/ReflectingPool.java | 2 +- .../test/cards/mana/ConditionalManaTest.java | 4 ++++ .../mana/AnyColorLandsProduceManaAbility.java | 24 ++++++++++++++++--- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Mage.Sets/src/mage/cards/n/NagaVitalist.java b/Mage.Sets/src/mage/cards/n/NagaVitalist.java index d679879b4d..d52127c688 100644 --- a/Mage.Sets/src/mage/cards/n/NagaVitalist.java +++ b/Mage.Sets/src/mage/cards/n/NagaVitalist.java @@ -50,7 +50,7 @@ public class NagaVitalist extends CardImpl { this.toughness = new MageInt(2); // {T}: Add to your mana pool one mana of any type that a land you control could produce. - this.addAbility(new AnyColorLandsProduceManaAbility(TargetController.YOU)); + this.addAbility(new AnyColorLandsProduceManaAbility(TargetController.YOU, false)); } public NagaVitalist(final NagaVitalist card) { diff --git a/Mage.Sets/src/mage/cards/r/ReflectingPool.java b/Mage.Sets/src/mage/cards/r/ReflectingPool.java index 713c7ca6dd..d28543994e 100644 --- a/Mage.Sets/src/mage/cards/r/ReflectingPool.java +++ b/Mage.Sets/src/mage/cards/r/ReflectingPool.java @@ -44,7 +44,7 @@ public class ReflectingPool extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.LAND}, ""); // {T}: Add to your mana pool one mana of any type that a land you control could produce. - this.addAbility(new AnyColorLandsProduceManaAbility(TargetController.YOU)); + this.addAbility(new AnyColorLandsProduceManaAbility(TargetController.YOU, false)); } public ReflectingPool(final ReflectingPool card) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/mana/ConditionalManaTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/mana/ConditionalManaTest.java index c4f3ad3739..4c68018520 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/mana/ConditionalManaTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/mana/ConditionalManaTest.java @@ -90,11 +90,15 @@ public class ConditionalManaTest extends CardTestPlayerBase { @Test public void testWorkingWithReflectingPool2() { addCard(Zone.BATTLEFIELD, playerA, "Reflecting Pool", 1); // can create white mana without restriction from the Hive + // {T}: Add {C} to your mana pool. + // {T}: Add one mana of any color to your mana pool. Spend this mana only to cast a Sliver spell. + // {5}, {T}: Create a 1/1 colorless Sliver creature token. Activate this ability only if you control a Sliver. addCard(Zone.BATTLEFIELD, playerA, "Sliver Hive", 1); addCard(Zone.HAND, playerA, "Silvercoat Lion", 1); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {C} to your mana pool"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add to your mana pool one mana of any type"); + setChoice(playerA, "White"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion"); diff --git a/Mage/src/main/java/mage/abilities/mana/AnyColorLandsProduceManaAbility.java b/Mage/src/main/java/mage/abilities/mana/AnyColorLandsProduceManaAbility.java index a810128427..3a6b662e4c 100644 --- a/Mage/src/main/java/mage/abilities/mana/AnyColorLandsProduceManaAbility.java +++ b/Mage/src/main/java/mage/abilities/mana/AnyColorLandsProduceManaAbility.java @@ -53,7 +53,11 @@ import mage.players.Player; public class AnyColorLandsProduceManaAbility extends ActivatedManaAbilityImpl { public AnyColorLandsProduceManaAbility(TargetController targetController) { - super(Zone.BATTLEFIELD, new AnyColorLandsProduceManaEffect(targetController), new TapSourceCost()); + this(targetController, true); + } + + public AnyColorLandsProduceManaAbility(TargetController targetController, boolean onlyColors) { + super(Zone.BATTLEFIELD, new AnyColorLandsProduceManaEffect(targetController, onlyColors), new TapSourceCost()); } public AnyColorLandsProduceManaAbility(final AnyColorLandsProduceManaAbility ability) { @@ -80,19 +84,23 @@ public class AnyColorLandsProduceManaAbility extends ActivatedManaAbilityImpl { class AnyColorLandsProduceManaEffect extends ManaEffect { private final FilterPermanent filter; + private final boolean onlyColors; // false if mana types can be produced (also Colorless mana), if false only colors can be produced (no Colorless mana). + private boolean inManaTypeCalculation = false; - public AnyColorLandsProduceManaEffect(TargetController targetController) { + public AnyColorLandsProduceManaEffect(TargetController targetController, boolean onlyColors) { super(); filter = new FilterLandPermanent(); + this.onlyColors = onlyColors; filter.add(new ControllerPredicate(targetController)); String text = targetController == TargetController.OPPONENT ? "an opponent controls" : "you control"; - staticText = "Add to your mana pool one mana of any color that a land " + text + " could produce"; + staticText = "Add to your mana pool one mana of any " + (this.onlyColors ? "color" : "type") + " that a land " + text + " could produce"; } public AnyColorLandsProduceManaEffect(final AnyColorLandsProduceManaEffect effect) { super(effect); this.filter = effect.filter.copy(); + this.onlyColors = effect.onlyColors; } @Override @@ -116,12 +124,19 @@ class AnyColorLandsProduceManaEffect extends ManaEffect { if (types.getWhite() > 0) { choice.getChoices().add("White"); } + if (!onlyColors && types.getColorless() > 0) { + choice.getChoices().add("Colorless"); + } if (types.getAny() > 0) { choice.getChoices().add("Black"); choice.getChoices().add("Red"); choice.getChoices().add("Blue"); choice.getChoices().add("Green"); choice.getChoices().add("White"); + if (!onlyColors) { + choice.getChoices().add("Colorless"); + } + } if (!choice.getChoices().isEmpty()) { Player player = game.getPlayer(source.getControllerId()); @@ -148,6 +163,9 @@ class AnyColorLandsProduceManaEffect extends ManaEffect { case "White": mana.setWhite(1); break; + case "Colorless": + mana.setColorless(1); + break; } checkToFirePossibleEvents(mana, game, source); player.getManaPool().addMana(mana, game, source);