* Yavimaya Dryad - Fixed that the Forest was put onto battlefield under controllers control instead of target players control.

This commit is contained in:
LevelX2 2015-12-13 17:21:24 +01:00
parent 6982caed33
commit 0c3d820e25

View file

@ -29,14 +29,21 @@ package mage.sets.archenemy;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.abilities.effects.SearchEffect;
import mage.abilities.keyword.ForestwalkAbility;
import mage.cards.CardImpl;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterLandCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInLibrary;
/**
@ -61,7 +68,9 @@ public class YavimayaDryad extends CardImpl {
// Forestwalk
this.addAbility(new ForestwalkAbility());
// When Yavimaya Dryad enters the battlefield, you may search your library for a Forest card and put it onto the battlefield tapped under target player's control. If you do, shuffle your library.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), true), true));
Ability ability = new EntersBattlefieldTriggeredAbility(new YavimayaDryadEffect(new TargetCardInLibrary(filter)), true);
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
}
public YavimayaDryad(final YavimayaDryad card) {
@ -73,3 +82,38 @@ public class YavimayaDryad extends CardImpl {
return new YavimayaDryad(this);
}
}
class YavimayaDryadEffect extends SearchEffect {
public YavimayaDryadEffect(TargetCardInLibrary target) {
super(target, Outcome.PutLandInPlay);
staticText = "you may search your library for a Forest card and put it onto the battlefield tapped under target player's control. If you do, shuffle your library";
}
public YavimayaDryadEffect(final YavimayaDryadEffect effect) {
super(effect);
}
@Override
public YavimayaDryadEffect copy() {
return new YavimayaDryadEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller == null || targetPlayer == null) {
return false;
}
if (controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
targetPlayer.moveCards(new CardsImpl(target.getTargets()).getCards(game),
Zone.BATTLEFIELD, source, game, true, false, false, null);
}
controller.shuffleLibrary(game);
return true;
}
return false;
}
}