* Notion Thief - Fixed that the replacment effect was not always applied as intended.

This commit is contained in:
LevelX2 2015-06-26 15:16:33 +02:00
parent 5b7d57aec9
commit d65581809f
3 changed files with 44 additions and 16 deletions

View file

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

View file

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

View file

@ -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());
}
}
/**
* 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);
}
}