From d65581809f61799f3b52e45ecb14456a724231e2 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 26 Jun 2015 15:16:33 +0200 Subject: [PATCH] * Notion Thief - Fixed that the replacment effect was not always applied as intended. --- .../sets/divinevsdemonic/FaithsFetters.java | 11 +++--- .../mage/sets/dragonsmaze/NotionThief.java | 11 +++--- .../cards/replacement/DrawEffectsTest.java | 38 ++++++++++++++++--- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/Mage.Sets/src/mage/sets/divinevsdemonic/FaithsFetters.java b/Mage.Sets/src/mage/sets/divinevsdemonic/FaithsFetters.java index 56e3cfd338..e586bbed0c 100644 --- a/Mage.Sets/src/mage/sets/divinevsdemonic/FaithsFetters.java +++ b/Mage.Sets/src/mage/sets/divinevsdemonic/FaithsFetters.java @@ -61,15 +61,16 @@ public class FaithsFetters extends CardImpl { this.expansionSetCode = "DDC"; this.subtype.add("Aura"); - // Enchant permanent TargetPermanent auraTarget = new TargetPermanent(); this.getSpellAbility().addTarget(auraTarget); - this.getSpellAbility().addEffect(new AttachEffect(Outcome.GainControl)); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.LoseAbility)); Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(ability); + // When Faith's Fetters enters the battlefield, you gain 4 life. this.addAbility(new EntersBattlefieldTriggeredAbility(new GainLifeEffect(4))); + // Enchanted permanent can't attack or block, and its activated abilities can't be activated unless they're mana abilities. Effect effect = new CantAttackBlockAttachedEffect(AttachmentType.AURA); effect.setText("Enchanted permanent can't attack or block,"); @@ -108,12 +109,12 @@ class FaithsFettersEffect extends ContinuousRuleModifyingEffectImpl { public boolean apply(Game game, Ability source) { return true; } - + @Override public boolean checksEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.ACTIVATE_ABILITY; } - + @Override public boolean applies(GameEvent event, Ability source, Game game) { Permanent enchantment = game.getPermanent(source.getSourceId()); @@ -127,4 +128,4 @@ class FaithsFettersEffect extends ContinuousRuleModifyingEffectImpl { } return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/NotionThief.java b/Mage.Sets/src/mage/sets/dragonsmaze/NotionThief.java index b5f2bcc03c..b7491e9e01 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/NotionThief.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/NotionThief.java @@ -37,6 +37,7 @@ import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Outcome; +import mage.constants.PhaseStep; import mage.constants.Rarity; import mage.constants.Zone; import mage.game.Game; @@ -76,7 +77,6 @@ public class NotionThief extends CardImpl { } } - class NotionThiefReplacementEffect extends ReplacementEffectImpl { public NotionThiefReplacementEffect() { @@ -106,21 +106,22 @@ class NotionThiefReplacementEffect extends ReplacementEffectImpl { } return true; } - + @Override public boolean checksEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.DRAW_CARD; - } - + } + @Override public boolean applies(GameEvent event, Ability source, Game game) { if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { - if (game.getActivePlayerId().equals(event.getPlayerId())) { + if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getStep().getType().equals(PhaseStep.DRAW)) { CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get("CardsDrawnDuringDrawStep"); if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) { return true; } } else { + // not an opponents players draw step, always replace draw return true; } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/replacement/DrawEffectsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/DrawEffectsTest.java index 106ef6fe6f..e5141680ac 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/replacement/DrawEffectsTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/DrawEffectsTest.java @@ -37,23 +37,49 @@ import org.mage.test.serverside.base.CardTestPlayerBase; * * @author LevelX2 */ - public class DrawEffectsTest extends CardTestPlayerBase { /** - * The effects of multiple Thought Reflections are cumulative. For example, if you have - * three Thought Reflections on the battlefield, you'll draw eight times the original number of cards. + * The effects of multiple Thought Reflections are cumulative. For example, + * if you have three Thought Reflections on the battlefield, you'll draw + * eight times the original number of cards. */ @Test public void testCard() { - // If you would draw a card, draw two cards instead. + // If you would draw a card, draw two cards instead. addCard(Zone.BATTLEFIELD, playerB, "Thought Reflection", 3); setStopAt(2, PhaseStep.PRECOMBAT_MAIN); execute(); - Assert.assertEquals("Player B has to have 4 cards in hand", 8 , playerB.getHand().size()); + Assert.assertEquals("Player B has to have 4 cards in hand", 8, playerB.getHand().size()); } -} \ No newline at end of file + /** + * http://www.slightlymagic.net/forum/viewtopic.php?f=70&t=17295&start=75#p181427 + * If I have a Notion Thief on the battlefield and cast Opportunity, + * targeting my opponent, during my opponent's upkeep, the opponent + * incorrectly draws the cards. + */ + @Test + public void testNotionThief() { + addCard(Zone.BATTLEFIELD, playerA, "Island", 6); + // Flash + // If an opponent would draw a card except the first one he or she draws in each of his or her draw steps, instead that player skips that draw and you draw a card. + addCard(Zone.BATTLEFIELD, playerA, "Notion Thief", 1); + + // Target player draws four cards. + addCard(Zone.HAND, playerA, "Opportunity", 1); + + castSpell(2, PhaseStep.UPKEEP, playerA, "Opportunity", playerB); + + setStopAt(2, PhaseStep.PRECOMBAT_MAIN); + execute(); + + assertGraveyardCount(playerA, "Opportunity", 1); + assertHandCount(playerA, 4); + assertHandCount(playerB, 1); + } + +}