diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/protection/gain/GainProtectionTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/protection/gain/GainProtectionTest.java index 945d61b8325..d3bb9c3eea8 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/protection/gain/GainProtectionTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/protection/gain/GainProtectionTest.java @@ -70,4 +70,64 @@ public class GainProtectionTest extends CardTestPlayerBase { assertPowerToughness(playerA, "Elite Vanguard", 6, 5); } + @Test + public void testGainProtectionByEnchantment() { + addCard(Zone.BATTLEFIELD, playerB, "Plains", 5); + // Flying + // When Brago, King Eternal deals combat damage to a player, exile any number of target nonland permanents you control, then return those cards to the battlefield under their owner's control. + addCard(Zone.BATTLEFIELD, playerB, "Brago, King Eternal"); + // Enchant creature + // When Pentarch Ward enters the battlefield, draw a card. + // As Pentarch Ward enters the battlefield, choose a color. + // Enchanted creature has protection from the chosen color. This effect doesn't remove Pentarch Ward. + addCard(Zone.HAND, playerB, "Pentarch Ward");// "{2}{W}" + // Enchant creature + // Enchanted creature gets +1/+1 and has "Whenever this creature attacks, tap target creature defending player controls." + addCard(Zone.HAND, playerB, "Grasp of the Hieromancer"); + + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Pentarch Ward", "Brago, King Eternal"); + setChoice(playerB, "White"); + + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Grasp of the Hieromancer", "Brago, King Eternal"); + + setStopAt(2, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerB, "Pentarch Ward", 1); + assertHandCount(playerB, "Grasp of the Hieromancer", 1); + assertHandCount(playerB, 3); + } + + /** + * Pentarch Ward on Brago naming white. Brago combat trigger resolves + * blinking Pentarch Ward. Brago retains protection from white even though + * Pentarch Ward is now exiled, making him unable to be re-enchanted by + * Pentarch Ward. + */ + @Test + public void testGainLooseProtectionByEnchantment() { + addCard(Zone.BATTLEFIELD, playerB, "Plains", 3); + // Flying + // When Brago, King Eternal deals combat damage to a player, exile any number of target nonland permanents you control, then return those cards to the battlefield under their owner's control. + addCard(Zone.BATTLEFIELD, playerB, "Brago, King Eternal"); + // Enchant creature + // When Pentarch Ward enters the battlefield, draw a card. + // As Pentarch Ward enters the battlefield, choose a color. + // Enchanted creature has protection from the chosen color. This effect doesn't remove Pentarch Ward. + addCard(Zone.HAND, playerB, "Pentarch Ward");// "{2}{W}" + + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Pentarch Ward", "Brago, King Eternal"); + setChoice(playerB, "White"); + + attack(2, playerB, "Brago, King Eternal"); + addTarget(playerB, "Pentarch Ward"); + addTarget(playerB, "Brago, King Eternal"); + + setStopAt(2, PhaseStep.END_COMBAT); + execute(); + + assertLife(playerA, 18); + assertPermanentCount(playerB, "Pentarch Ward", 1); + assertHandCount(playerB, 3); + } } diff --git a/Mage/src/mage/abilities/effects/AuraReplacementEffect.java b/Mage/src/mage/abilities/effects/AuraReplacementEffect.java index 8c4a0e063e9..1a47387a473 100644 --- a/Mage/src/mage/abilities/effects/AuraReplacementEffect.java +++ b/Mage/src/mage/abilities/effects/AuraReplacementEffect.java @@ -116,6 +116,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl { } } + game.applyEffects(); // So continuousEffects are removed if previous effect of the same ability did move objects that cuase continuous effects if (targetId == null) { Target target = card.getSpellAbility().getTargets().get(0); enchantCardInGraveyard = target instanceof TargetCardInGraveyard; @@ -169,7 +170,6 @@ public class AuraReplacementEffect extends ReplacementEffectImpl { PermanentCard permanent = new PermanentCard(card, card.getOwnerId(), game); game.getBattlefield().addPermanent(permanent); card.setZone(Zone.BATTLEFIELD, game); - game.applyEffects(); boolean entered = permanent.entersBattlefield(event.getSourceId(), game, fromZone, true); game.applyEffects(); if (!entered) { diff --git a/Mage/src/mage/abilities/effects/common/ReturnFromExileEffect.java b/Mage/src/mage/abilities/effects/common/ReturnFromExileEffect.java index a3eeb0a2c13..58ebc6676bb 100644 --- a/Mage/src/mage/abilities/effects/common/ReturnFromExileEffect.java +++ b/Mage/src/mage/abilities/effects/common/ReturnFromExileEffect.java @@ -96,7 +96,7 @@ public class ReturnFromExileEffect extends OneShotEffect { case BATTLEFIELD: card.moveToZone(zone, source.getSourceId(), game, tapped); if (!game.isSimulation()) { - game.informPlayers(controller.getLogName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase()); + game.informPlayers(controller.getLogName() + " moves " + card.getLogName() + " to " + zone.toString().toLowerCase()); } break; case HAND: @@ -111,7 +111,7 @@ public class ReturnFromExileEffect extends OneShotEffect { default: card.moveToZone(zone, source.getSourceId(), game, tapped); if (!game.isSimulation()) { - game.informPlayers(controller.getLogName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase()); + game.informPlayers(controller.getLogName() + " moves " + card.getLogName() + " to " + zone.toString().toLowerCase()); } } }