From d344fdec504319db8994ec148b10d48413b8a2b2 Mon Sep 17 00:00:00 2001 From: Alex Vasile <48962821+Alex-Vasile@users.noreply.github.com> Date: Mon, 4 Jul 2022 22:23:44 -0400 Subject: [PATCH] Fixed Fable Passage so that it has correct interaction with Amulet of Vigor (#9224) --- Mage.Sets/src/mage/cards/f/FabledPassage.java | 70 +++++++++++++++---- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/Mage.Sets/src/mage/cards/f/FabledPassage.java b/Mage.Sets/src/mage/cards/f/FabledPassage.java index 237de41a821..ce6a2c90e8f 100644 --- a/Mage.Sets/src/mage/cards/f/FabledPassage.java +++ b/Mage.Sets/src/mage/cards/f/FabledPassage.java @@ -4,6 +4,7 @@ import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; @@ -15,7 +16,10 @@ import mage.filter.StaticFilters; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; +import mage.target.TargetCard; import mage.target.common.TargetCardInLibrary; +import mage.target.targetpointer.FirstTargetPointer; +import mage.target.targetpointer.FixedTarget; import java.util.UUID; @@ -27,9 +31,11 @@ public final class FabledPassage extends CardImpl { public FabledPassage(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.LAND}, ""); - // {T}, Sacrifice Fabled Passage: Search your library for a basic land card, put it onto the battlefield tapped, then shuffle your library. Then if you control four or more lands, untap that land. - Ability ability = new SimpleActivatedAbility(new FabledPassageEffect(), new TapSourceCost()); + // {T}, Sacrifice Fabled Passage: Search your library for a basic land card, put it onto the battlefield tapped, then shuffle your library. + // Then if you control four or more lands, untap that land. + Ability ability = new SimpleActivatedAbility(new FabledPassageSearchForLandEffect(), new TapSourceCost()); ability.addCost(new SacrificeSourceCost()); + ability.addEffect(new FabledPassageUntapLandEffect()); this.addAbility(ability); } @@ -43,21 +49,20 @@ public final class FabledPassage extends CardImpl { } } -class FabledPassageEffect extends OneShotEffect { +class FabledPassageSearchForLandEffect extends OneShotEffect { - FabledPassageEffect() { - super(Outcome.Benefit); - staticText = "Search your library for a basic land card, put it onto the battlefield tapped, " + - "then shuffle. Then if you control four or more lands, untap that land."; + FabledPassageSearchForLandEffect() { + super(Outcome.PutCardInPlay); + staticText = "Search your library for a basic land card, put it onto the battlefield tapped, then shuffle "; } - private FabledPassageEffect(final FabledPassageEffect effect) { + private FabledPassageSearchForLandEffect(final FabledPassageSearchForLandEffect effect) { super(effect); } @Override - public FabledPassageEffect copy() { - return new FabledPassageEffect(this); + public FabledPassageSearchForLandEffect copy() { + return new FabledPassageSearchForLandEffect(this); } @Override @@ -78,13 +83,50 @@ class FabledPassageEffect extends OneShotEffect { if (!player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null)) { return false; } + for (Effect effect : source.getEffects()) { + if (effect instanceof FabledPassageUntapLandEffect) { + effect.setTargetPointer(new FixedTarget(card, game)); + return true; + } + } + + return true; + } +} + +// Need to be split across two effects so that other cards (e.g. Amulet of Vigor) +// see the land enterring tapped (before this part of the effect untaps it). +class FabledPassageUntapLandEffect extends OneShotEffect { + + FabledPassageUntapLandEffect() { + super(Outcome.Untap); + staticText = "Then if you control four or more lands, untap that land."; + } + + @Override + public boolean apply(Game game, Ability source) { + Card targetLandCard = game.getCard(getTargetPointer().getFirst(game, source)); + if (targetLandCard == null) { + return false; + } + if (game.getBattlefield().countAll(StaticFilters.FILTER_LAND, source.getControllerId(), game) < 4) { return true; } - Permanent permanent = game.getPermanent(card.getId()); - if (permanent == null) { + + Permanent land = game.getPermanent(targetLandCard.getId()); + if (land == null) { return false; } - return permanent.untap(game); + return land.untap(game); } -} + + private FabledPassageUntapLandEffect(final FabledPassageUntapLandEffect effect) { + super(effect); + } + + @Override + public FabledPassageUntapLandEffect copy() { + return new FabledPassageUntapLandEffect(this); + } +} \ No newline at end of file