- ReturnFromGraveyardToHandTargetEffect() will now check to verify the target card is still in the graveyard.

This commit is contained in:
Jeff 2019-04-25 15:22:08 -05:00
parent 087c437658
commit d8a928051a
2 changed files with 12 additions and 40 deletions

View file

@ -48,39 +48,3 @@ public final class GreenwardenOfMurasa extends CardImpl {
return new GreenwardenOfMurasa(this); return new GreenwardenOfMurasa(this);
} }
} }
//class GreenwardenOfMurasaEffect extends OneShotEffect {
//
// public GreenwardenOfMurasaEffect() {
// super(Outcome.Benefit);
// this.staticText = "you may exile it. If you do, return target card from your graveyard to your hand";
// }
//
// public GreenwardenOfMurasaEffect(final GreenwardenOfMurasaEffect effect) {
// super(effect);
// }
//
// @Override
// public GreenwardenOfMurasaEffect copy() {
// return new GreenwardenOfMurasaEffect(this);
// }
//
// @Override
// public boolean apply(Game game, Ability source) {
// Player controller = game.getPlayer(source.getControllerId());
// MageObject sourceObject = game.getObject(source.getSourceId());
// Card targetCard = game.getCard(getTargetPointer().getFirst(game, source));
// if (controller != null && sourceObject != null && targetCard != null) {
// if (controller.chooseUse(outcome, "Exile " + sourceObject.getLogName() + " to return card from your graveyard to your hand?", source, game)) {
// // Setting the fixed target prevents to return Greenwarden of Murasa itself (becuase it's exiled meanwhile),
// // but of course you can target it as the ability triggers I guess
// Effect effect = new ReturnToHandTargetEffect();
// effect.setTargetPointer(new FixedTarget(targetCard.getId(), targetCard.getZoneChangeCounter(game)));
// new ExileSourceEffect().apply(game, source);
// return effect.apply(game, source);
// }
// return true;
// }
// return false;
// }
//}

View file

@ -1,9 +1,10 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
@ -34,8 +35,15 @@ public class ReturnFromGraveyardToHandTargetEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller == null) {
return controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)), Zone.HAND, source, game); return false;
}
Cards cardsInGraveyard = new CardsImpl(getTargetPointer().getTargets(game, source));
for (Card card : cardsInGraveyard.getCards(game)) {
if (card != null
&& game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
controller.moveCards(card, Zone.HAND, source, game); //verify the target card is still in the graveyard
}
} }
return false; return false;
} }