Fixed Fable Passage so that it has correct interaction with Amulet of Vigor (#9224)

This commit is contained in:
Alex Vasile 2022-07-04 22:23:44 -04:00 committed by GitHub
parent 7dd6b03a3b
commit d344fdec50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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