* Archangel Avacyn - Fixed check for source object of triggered ability.

This commit is contained in:
LevelX2 2016-08-13 09:38:28 +02:00
parent 46566361e7
commit 4bfac31370
6 changed files with 64 additions and 11 deletions

View file

@ -54,7 +54,7 @@ public class PharagaxGiant extends CardImpl {
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// Tribute 2
// Tribute 2 (As this creature enters the battlefield, an opponent of your choice may place two +1/+1 counters on it.)
this.addAbility(new TributeAbility(2));
// When Pharagax Giant enters the battlefield, if tribute wasn't paid, Pharagax Giant deals 5 damage to each opponent.
TriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new DamagePlayersEffect(5, TargetController.OPPONENT), false);

View file

@ -71,7 +71,7 @@ public class EldraziDisplacer extends CardImpl {
effect.setText("Exile another target creature");
effect.setApplyEffectsAfter(); // Needed to let temporary continuous effects end if a permanent is blinked
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl<>("{2}{C}"));
effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(true);
effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(true, true);
effect.setText(", then return it to the battlefield tapped under its owner's control");
ability.addEffect(effect);
ability.addTarget(new TargetCreaturePermanent(FILTER));

View file

@ -29,12 +29,14 @@ package mage.sets.shadowsoverinnistrad;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.DiesCreatureTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.TransformSourceEffect;
import mage.abilities.effects.common.TransformTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.abilities.keyword.FlashAbility;
import mage.abilities.keyword.FlyingAbility;
@ -53,6 +55,8 @@ import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -124,10 +128,16 @@ class ArchangelAvacynEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
//create delayed triggered ability
AtTheBeginOfNextUpkeepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(new TransformSourceEffect(true));
game.addDelayedTriggeredAbility(delayedAbility, source);
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
if (sourceObject instanceof Permanent) {
//create delayed triggered ability
Effect effect = new TransformTargetEffect(false);
effect.setTargetPointer(new FixedTarget((Permanent) sourceObject, game));
AtTheBeginOfNextUpkeepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
return true;
}
@Override

View file

@ -284,4 +284,41 @@ public class TransformTest extends CardTestPlayerBase {
assertPermanentCount(playerB, "Unimpeded Trespasser", 1);
assertPowerToughness(playerB, "Unimpeded Trespasser", 3, 3);
}
/**
* Archangel Avacyn still transforms after being bounced by an Eldrazi
* Displacer with her trigger on the stack.
*/
@Test
public void testTransformArchangelAvacyn() {
// Flash, Flying, Vigilance
// When Archangel Avacyn enters the battlefield, creatures you control gain indestructible until end of turn.
// When a non-Angel creature you control dies, transform Archangel Avacyn at the beginning of the next upkeep.
addCard(Zone.BATTLEFIELD, playerA, "Archangel Avacyn"); // Creature 4/4
// Transformed side: Avacyn, the Purifier - Creature 6/5
// Flying
// When this creature transforms into Avacyn, the Purifier, it deals 3 damage to each other creature and each opponent.
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
addCard(Zone.HAND, playerA, "Lightning Bolt");
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
// Devoid
// {2}{C}: Exile another target creature, then return it to the battlefield tapped under its owner's control.
addCard(Zone.BATTLEFIELD, playerB, "Eldrazi Displacer", 1);
addCard(Zone.BATTLEFIELD, playerB, "Wastes", 3);
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Silvercoat Lion");
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "{2}{C}", "Archangel Avacyn", "Whenever a non-Angel creature you control dies");
setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
execute();
assertGraveyardCount(playerA, "Lightning Bolt", 1);
assertGraveyardCount(playerA, "Silvercoat Lion", 1);
assertPermanentCount(playerB, "Eldrazi Displacer", 1);
assertPermanentCount(playerA, "Avacyn, the Purifier", 0);
assertPermanentCount(playerA, "Archangel Avacyn", 1);
}
}

View file

@ -32,6 +32,9 @@ public class ArchangelAvacynTest extends CardTestPlayerBase {
// Vigilance
// When Archangel Avacyn enters the battlefield, creatures you control gain indestructible until end of turn.
// When a non-Angel creature you control dies, transform Archangel Avacyn at the beginning of the next upkeep.
// Transformed side: Avacyn, the Purifier - Creature 6/5
// Flying
// When this creature transforms into Avacyn, the Purifier, it deals 3 damage to each other creature and each opponent.
addCard(Zone.BATTLEFIELD, playerA, "Archangel Avacyn");
addCard(Zone.BATTLEFIELD, playerA, "Wall of Omens"); // 0/4
addCard(Zone.HAND, playerA, "Elite Vanguard"); // 2/1
@ -42,19 +45,20 @@ public class ArchangelAvacynTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Elite Vanguard");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Shock");
addTarget(playerB, "Elite Vanguard");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Shock", "Elite Vanguard");
setStopAt(3, PhaseStep.DRAW);
execute();
assertGraveyardCount(playerB, "Shock", 1);
assertPermanentCount(playerA, "Avacyn, the Purifier", 1);
assertPermanentCount(playerA, "Wall of Omens", 1);
assertGraveyardCount(playerA, "Elite Vanguard", 1);
assertPermanentCount(playerB, "Wall of Roots", 1);
assertGraveyardCount(playerB, "Hill Giant", 1);
assertGraveyardCount(playerB, "Shock", 1);
Permanent avacyn = getPermanent("Avacyn, the Purifier", playerA);
Assert.assertEquals("Damage to Avacyn, the Purifier should be 0 not 3", 0, avacyn.getDamage());
assertGraveyardCount(playerB, "Hill Giant", 1);
}
}

View file

@ -76,7 +76,9 @@ public class TransformTargetEffect extends OneShotEffect {
if (staticText != null && staticText.length() > 0) {
return staticText;
}
if (mode.getTargets().isEmpty()) {
return "transform target";
}
Target target = mode.getTargets().get(0);
if (target.getMaxNumberOfTargets() > 1) {
if (target.getMaxNumberOfTargets() == target.getNumberOfTargets()) {