* Emira Shepherd - Fixed that the returned card could be returned to battlefield if the played land was a Plains.

This commit is contained in:
LevelX2 2015-09-20 09:46:19 +02:00
parent 1d9cebfc5c
commit 24d555f41c
2 changed files with 49 additions and 3 deletions

View file

@ -31,14 +31,20 @@ import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.LandfallAbility; import mage.abilities.common.LandfallAbility;
import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardsImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterPermanentCard; import mage.filter.common.FilterPermanentCard;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
/** /**
@ -62,8 +68,9 @@ public class EmeriaShepherd extends CardImpl {
// Flying // Flying
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// <i>Landfall</i> Whenever a land enters the battlefield under your control, you may return target nonland permanent card from your graveyard to your hand. If that land is a Plains, you may return that nonland permanent card to the battlefield instead. // <i>Landfall</i> Whenever a land enters the battlefield under your control, you may return target nonland permanent card from your graveyard to your hand.
Ability ability = new LandfallAbility(new ReturnToHandTargetEffect(), true); // If that land is a Plains, you may return that nonland permanent card to the battlefield instead.
Ability ability = new LandfallAbility(Zone.BATTLEFIELD, new EmeriaShepherdReturnToHandTargetEffect(), true);
ability.addTarget(new TargetCardInYourGraveyard(new FilterPermanentCard(filter))); ability.addTarget(new TargetCardInYourGraveyard(new FilterPermanentCard(filter)));
this.addAbility(ability); this.addAbility(ability);
} }
@ -77,3 +84,36 @@ public class EmeriaShepherd extends CardImpl {
return new EmeriaShepherd(this); return new EmeriaShepherd(this);
} }
} }
class EmeriaShepherdReturnToHandTargetEffect extends OneShotEffect {
public EmeriaShepherdReturnToHandTargetEffect() {
super(Outcome.ReturnToHand);
staticText = "you may return target nonland permanent card from your graveyard to your hand. If that land is a Plains, you may return that nonland permanent card to the battlefield instead";
}
public EmeriaShepherdReturnToHandTargetEffect(final EmeriaShepherdReturnToHandTargetEffect effect) {
super(effect);
}
@Override
public EmeriaShepherdReturnToHandTargetEffect copy() {
return new EmeriaShepherdReturnToHandTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent triggeringLand = ((LandfallAbility) source).getTriggeringPermanent();
if (controller == null || triggeringLand == null) {
return false;
}
Zone toZone = Zone.HAND;
if (triggeringLand.getSubtype().contains("Plains")
&& controller.chooseUse(Outcome.PutCardInPlay, "Put the card to battlefield instead?", source, game)) {
toZone = Zone.BATTLEFIELD;
}
return controller.moveCards(new CardsImpl(targetPointer.getTargets(game, source)), null, toZone, source, game);
}
}

View file

@ -44,6 +44,7 @@ import mage.target.targetpointer.FixedTarget;
public class LandfallAbility extends TriggeredAbilityImpl { public class LandfallAbility extends TriggeredAbilityImpl {
protected SetTargetPointer setTargetPointer; protected SetTargetPointer setTargetPointer;
protected Permanent triggeringLand;
public LandfallAbility(Effect effect, boolean optional) { public LandfallAbility(Effect effect, boolean optional) {
this(Zone.BATTLEFIELD, effect, optional); this(Zone.BATTLEFIELD, effect, optional);
@ -61,6 +62,7 @@ public class LandfallAbility extends TriggeredAbilityImpl {
public LandfallAbility(final LandfallAbility ability) { public LandfallAbility(final LandfallAbility ability) {
super(ability); super(ability);
this.setTargetPointer = ability.setTargetPointer; this.setTargetPointer = ability.setTargetPointer;
this.triggeringLand = ability.triggeringLand;
} }
@Override @Override
@ -74,6 +76,7 @@ public class LandfallAbility extends TriggeredAbilityImpl {
if (permanent != null if (permanent != null
&& permanent.getCardType().contains(CardType.LAND) && permanent.getCardType().contains(CardType.LAND)
&& permanent.getControllerId().equals(this.controllerId)) { && permanent.getControllerId().equals(this.controllerId)) {
triggeringLand = permanent;
if (setTargetPointer.equals(SetTargetPointer.PERMANENT)) { if (setTargetPointer.equals(SetTargetPointer.PERMANENT)) {
for (Effect effect : getEffects()) { for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(permanent, game)); effect.setTargetPointer(new FixedTarget(permanent, game));
@ -94,4 +97,7 @@ public class LandfallAbility extends TriggeredAbilityImpl {
return new LandfallAbility(this); return new LandfallAbility(this);
} }
public Permanent getTriggeringPermanent() {
return triggeringLand;
}
} }