* 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.

This commit is contained in:
LevelX2 2017-07-23 22:49:56 +02:00
parent f67cd391dd
commit b948a8255a
4 changed files with 27 additions and 5 deletions

View file

@ -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) {

View file

@ -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) {

View file

@ -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");

View file

@ -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);