diff --git a/Mage.Sets/src/mage/cards/e/EmpoweredAutogenerator.java b/Mage.Sets/src/mage/cards/e/EmpoweredAutogenerator.java index 3d12f810c3c..9dcfa481d42 100644 --- a/Mage.Sets/src/mage/cards/e/EmpoweredAutogenerator.java +++ b/Mage.Sets/src/mage/cards/e/EmpoweredAutogenerator.java @@ -16,6 +16,8 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; /** @@ -30,6 +32,7 @@ public final class EmpoweredAutogenerator extends CardImpl { this.addAbility(new EntersBattlefieldTappedAbility()); // {T}: Put a charge counter on Empowered Autogenerator. Add X mana of any one color, where X is the number of charge counters on Empowered Autogenerator. + // Empowered Autogenerator's activated ability is a mana ability. It doesn’t use the stack and can’t be responded to. (2019-08-23) this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new EmpoweredAutogeneratorManaEffect(), new TapSourceCost())); } @@ -65,35 +68,34 @@ class EmpoweredAutogeneratorManaEffect extends ManaEffect { } @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - if (controller == null - || sourcePermanent == null) { - return false; - } - sourcePermanent.addCounters(CounterType.CHARGE.createInstance(), source, game); - checkToFirePossibleEvents(getMana(game, source), game, source); - controller.getManaPool().addMana(getMana(game, source), game, source); - return true; + public List getNetMana(Game game, Ability source) { + List netMana = new ArrayList<>(); + Permanent sourcePermanent = game.getState().getPermanent(source.getSourceId()); + if (sourcePermanent != null) { + int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE) + 1; // one counter will be added on real mana call + if (counters > 0) { + netMana.add(Mana.AnyMana(counters)); + } + } + + return netMana; } @Override - public Mana produceMana(boolean netMana, Game game, Ability source) { + public Mana produceMana(Game game, Ability source) { Mana mana = new Mana(); game.applyEffects(); Permanent sourcePermanent = game.getState().getPermanent(source.getSourceId()); if (sourcePermanent == null) { return mana; } - int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE) + 1; + + sourcePermanent.addCounters(CounterType.CHARGE.createInstance(), source, game); + int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE); if (counters == 0) { return mana; } - if (netMana) { - return new Mana(0, 0, 0, 0, 0, 0, counters, 0); - } Player controller = game.getPlayer(source.getControllerId()); if (controller == null) { return mana; diff --git a/Mage.Sets/src/mage/cards/f/FaeburrowElder.java b/Mage.Sets/src/mage/cards/f/FaeburrowElder.java index 6cfbe654307..056ea9a6a74 100644 --- a/Mage.Sets/src/mage/cards/f/FaeburrowElder.java +++ b/Mage.Sets/src/mage/cards/f/FaeburrowElder.java @@ -20,7 +20,6 @@ import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; -import mage.players.Player; import java.util.UUID; @@ -106,19 +105,7 @@ class FaeburrowElderManaEffect extends ManaEffect { } @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller == null) { - return false; - } - Mana mana = getMana(game, source); - checkToFirePossibleEvents(mana, game, source); - controller.getManaPool().addMana(mana, game, source); - return true; - } - - @Override - public Mana produceMana(boolean netMana, Game game, Ability source) { + public Mana produceMana(Game game, Ability source) { Mana mana = new Mana(); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) { if (mana.getBlack() == 0 && permanent.getColor(game).isBlack()) { diff --git a/Mage.Sets/src/mage/cards/n/NyxLotus.java b/Mage.Sets/src/mage/cards/n/NyxLotus.java index cc89d5c3291..f63afbd1cb2 100644 --- a/Mage.Sets/src/mage/cards/n/NyxLotus.java +++ b/Mage.Sets/src/mage/cards/n/NyxLotus.java @@ -95,18 +95,6 @@ class NyxLotusDynamicManaEffect extends ManaEffect { return new NyxLotusDynamicManaEffect(this); } - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller == null) { - return false; - } - checkToFirePossibleEvents(getMana(game, source), game, source); - controller.getManaPool().addMana(getMana(game, source), game, source); - return true; - - } - @Override public List getNetMana(Game game, Ability source) { return ChoiceColor.getBaseColors() @@ -117,7 +105,7 @@ class NyxLotusDynamicManaEffect extends ManaEffect { } @Override - public Mana produceMana(boolean netMana, Game game, Ability source) { + public Mana produceMana(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller == null) { return null; 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 ac8367bab6c..bfaac7e5592 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 @@ -3,12 +3,12 @@ package org.mage.test.cards.mana; import mage.abilities.keyword.FlyingAbility; import mage.constants.PhaseStep; import mage.constants.Zone; +import mage.counters.CounterType; import org.junit.Ignore; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; /** - * * @author LevelX2 */ public class ConditionalManaTest extends CardTestPlayerBase { @@ -209,4 +209,81 @@ public class ConditionalManaTest extends CardTestPlayerBase { assertLife(playerB, 18); } + + @Test + public void EmpoweredAutogeneratorAddsCountWithMana() { + // Empowered Autogenerator's activated ability is a mana ability. It doesn’t use the stack and can’t be responded to. (2019-08-23) + + // Empowered Autogenerator enters the battlefield tapped. + // {T}: Put a charge counter on Empowered Autogenerator. Add X mana of any one color, where X is the number of charge counters on Empowered Autogenerator. + addCard(Zone.BATTLEFIELD, playerA, "Empowered Autogenerator", 1); + // + addCard(Zone.HAND, playerA, "Lightning Bolt", 1); + + activateManaAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Put a charge counter"); + setChoice(playerA, "Red"); + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + + setStrictChooseMode(true); + setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); + execute(); + assertAllCommandsUsed(); + + assertCounterCount(playerA, "Empowered Autogenerator", CounterType.CHARGE, 1); + assertLife(playerB, 20 - 3); + } + + @Test + public void EmpoweredAutogeneratorAddsDoubleCountersWithDoubleSeason() { + // Empowered Autogenerator's activated ability is a mana ability. It doesn’t use the stack and can’t be responded to. (2019-08-23) + + // Empowered Autogenerator enters the battlefield tapped. + // {T}: Put a charge counter on Empowered Autogenerator. Add X mana of any one color, where X is the number of charge counters on Empowered Autogenerator. + addCard(Zone.BATTLEFIELD, playerA, "Empowered Autogenerator", 1); + // + addCard(Zone.HAND, playerA, "Lightning Bolt", 1); + // + // If an effect would put one or more tokens into play under your control, it puts twice that many of those tokens into play instead. + // If an effect would place one or more counters on a permanent you control, it places twice that many of those counters on that permanent instead. + addCard(Zone.BATTLEFIELD, playerA, "Doubling Season", 1); + + activateManaAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Put a charge counter"); + setChoice(playerA, "Red"); + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + + setStrictChooseMode(true); + setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); + execute(); + assertAllCommandsUsed(); + + assertCounterCount(playerA, "Empowered Autogenerator", CounterType.CHARGE, 2); + assertLife(playerB, 20 - 3); + } + + @Test + public void EmpoweredAutogeneratorAddsDoubleCountersWithDoubleSeason_AutoPay() { + // Empowered Autogenerator's activated ability is a mana ability. It doesn’t use the stack and can’t be responded to. (2019-08-23) + + // Empowered Autogenerator enters the battlefield tapped. + // {T}: Put a charge counter on Empowered Autogenerator. Add X mana of any one color, where X is the number of charge counters on Empowered Autogenerator. + addCard(Zone.BATTLEFIELD, playerA, "Empowered Autogenerator", 1); + // + addCard(Zone.HAND, playerA, "Lightning Bolt", 1); + // + // If an effect would put one or more tokens into play under your control, it puts twice that many of those tokens into play instead. + // If an effect would place one or more counters on a permanent you control, it places twice that many of those counters on that permanent instead. + addCard(Zone.BATTLEFIELD, playerA, "Doubling Season", 1); + + //activateManaAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Put a charge counter"); // auto pay + setChoice(playerA, "Red"); + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + + setStrictChooseMode(true); + setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); + execute(); + assertAllCommandsUsed(); + + assertCounterCount(playerA, "Empowered Autogenerator", CounterType.CHARGE, 2); + assertLife(playerB, 20 - 3); + } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ManaEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ManaEffect.java index 3fc0d872986..542656774c8 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ManaEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ManaEffect.java @@ -1,8 +1,5 @@ - package mage.abilities.effects.common; -import java.util.ArrayList; -import java.util.List; import mage.Mana; import mage.abilities.Ability; import mage.abilities.costs.Cost; @@ -13,11 +10,12 @@ import mage.constants.Outcome; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.ManaEvent; -import mage.players.ManaPool; import mage.players.Player; +import java.util.ArrayList; +import java.util.List; + /** - * * @author BetaSteward_at_googlemail.com */ public abstract class ManaEffect extends OneShotEffect { @@ -75,6 +73,9 @@ public abstract class ManaEffect extends OneShotEffect { /** * Produced the mana the effect can produce + * WARNING, produceMana can be called multiple times for mana and spell available calculations + * if you don't want it then overide getNetMana to return max possible mana values + * (if you have choose dialogs or extra effects like new counters in produceMana) * * @param game * @param source