From 860c57d9d93909a272d8cedcc4bfa2080bbd7761 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sun, 12 Jan 2020 10:09:51 +0400 Subject: [PATCH] * Chrom Mox - fixed that tapped for mana replacement effects ignore his mana; --- Mage.Sets/src/mage/cards/c/ChromeMox.java | 16 +++-- .../src/mage/cards/m/ManaReflection.java | 14 ++-- .../TappedForManaFromMultipleEffects.java | 64 +++++++++++++++++++ .../abilities/effects/common/ManaEffect.java | 3 +- 4 files changed, 80 insertions(+), 17 deletions(-) diff --git a/Mage.Sets/src/mage/cards/c/ChromeMox.java b/Mage.Sets/src/mage/cards/c/ChromeMox.java index fd98e01171..51c4baf994 100644 --- a/Mage.Sets/src/mage/cards/c/ChromeMox.java +++ b/Mage.Sets/src/mage/cards/c/ChromeMox.java @@ -192,24 +192,28 @@ class ChromeMoxManaEffect extends ManaEffect { } switch (choice.getChoice()) { case "Black": - player.getManaPool().addMana(Mana.BlackMana(1), game, source); + //player.getManaPool().addMana(Mana.BlackMana(1), game, source); + mana.add(Mana.BlackMana(1)); break; case "Blue": - player.getManaPool().addMana(Mana.BlueMana(1), game, source); + //player.getManaPool().addMana(Mana.BlueMana(1), game, source); + mana.add(Mana.BlueMana(1)); break; case "Red": - player.getManaPool().addMana(Mana.RedMana(1), game, source); + //player.getManaPool().addMana(Mana.RedMana(1), game, source); + mana.add(Mana.RedMana(1)); break; case "Green": - player.getManaPool().addMana(Mana.GreenMana(1), game, source); + //player.getManaPool().addMana(Mana.GreenMana(1), game, source); + mana.add(Mana.GreenMana(1)); break; case "White": - player.getManaPool().addMana(Mana.WhiteMana(1), game, source); + //player.getManaPool().addMana(Mana.WhiteMana(1), game, source); + mana.add(Mana.WhiteMana(1)); break; default: break; } - } return mana; } diff --git a/Mage.Sets/src/mage/cards/m/ManaReflection.java b/Mage.Sets/src/mage/cards/m/ManaReflection.java index e32e214f97..0a7dbbf5fa 100644 --- a/Mage.Sets/src/mage/cards/m/ManaReflection.java +++ b/Mage.Sets/src/mage/cards/m/ManaReflection.java @@ -1,34 +1,28 @@ - package mage.cards.m; -import java.util.UUID; import mage.Mana; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ReplacementEffectImpl; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.ManaType; -import mage.constants.Outcome; -import mage.constants.Zone; +import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.ManaEvent; +import java.util.UUID; + /** - * * @author jeffwadsworth */ public final class ManaReflection extends CardImpl { public ManaReflection(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{4}{G}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{G}{G}"); // If you tap a permanent for mana, it produces twice as much of that mana instead. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ManaReflectionReplacementEffect())); - } public ManaReflection(final ManaReflection card) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/TappedForManaFromMultipleEffects.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/TappedForManaFromMultipleEffects.java index aadc36ce6a..05b55fccd7 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/TappedForManaFromMultipleEffects.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/TappedForManaFromMultipleEffects.java @@ -69,4 +69,68 @@ public class TappedForManaFromMultipleEffects extends CardTestPlayerBase { assertPermanentCount(playerA, "Nyxbloom Ancient", 2); assertPermanentCount(playerA, "Chlorophant", 1); } + + @Test + public void test_ChromeMox_Direct() { + // Imprint — When Chrome Mox enters the battlefield, you may exile a nonartifact, nonland card from your hand. + // {T}: Add one mana of any of the exiled card’s colors. + addCard(Zone.HAND, playerA, "Chrome Mox", 1); // {0} + addCard(Zone.HAND, playerA, "Balduvian Bears", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Chrome Mox"); + setChoice(playerA, "Yes"); // use imprint + setChoice(playerA, "Balduvian Bears"); // discard + + activateManaAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{T}: Add one"); + checkManaPool("must produce green", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "G", 1); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, "Chrome Mox", 1); + assertExileCount(playerA, "Balduvian Bears", 1); + } + + @Test + public void test_ManaReflect_Direct() { + // If you tap a permanent for mana, it produces twice as much of that mana instead. + addCard(Zone.BATTLEFIELD, playerA, "Mana Reflection", 1); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); + + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}"); + checkManaPool("must produce green", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "G", 2); // double by reflection + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + } + + @Test + public void test_ChromeMox_WithManaReflect() { + // Imprint — When Chrome Mox enters the battlefield, you may exile a nonartifact, nonland card from your hand. + // {T}: Add one mana of any of the exiled card’s colors. + addCard(Zone.HAND, playerA, "Chrome Mox", 1); // {0} + addCard(Zone.HAND, playerA, "Balduvian Bears", 1); + // + // If you tap a permanent for mana, it produces twice as much of that mana instead. + addCard(Zone.BATTLEFIELD, playerA, "Mana Reflection", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Chrome Mox"); + setChoice(playerA, "Yes"); // use imprint + setChoice(playerA, "Balduvian Bears"); // discard + + activateManaAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{T}: Add one"); + checkManaPool("must produce green", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "G", 2); // double by reflection + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, "Chrome Mox", 1); + assertExileCount(playerA, "Balduvian Bears", 1); + } } \ No newline at end of file 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 542656774c..1690fb0b23 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ManaEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ManaEffect.java @@ -72,7 +72,8 @@ public abstract class ManaEffect extends OneShotEffect { } /** - * Produced the mana the effect can produce + * Produced the mana the effect can produce (DO NOT add it to mana pool -- return all added as mana object to process by replace events) + *

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