* Changed some more card movement handling.

This commit is contained in:
LevelX2 2015-10-22 23:02:07 +02:00
parent ff71654a5f
commit 92bcd0d522
17 changed files with 197 additions and 224 deletions

View file

@ -27,8 +27,8 @@
*/ */
package mage.sets.scarsofmirrodin; package mage.sets.scarsofmirrodin;
import mage.constants.CardType; import java.util.List;
import mage.constants.Rarity; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DiesTriggeredAbility; import mage.abilities.common.DiesTriggeredAbility;
@ -38,7 +38,9 @@ import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.game.Game; import mage.game.Game;
@ -46,9 +48,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import java.util.List;
import java.util.UUID;
/** /**
* @author nantuko * @author nantuko
*/ */
@ -161,19 +160,22 @@ class CloneShellDiesEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); Player controller = game.getPlayer(source.getControllerId());
if (permanent != null) { if (controller != null) {
List<UUID> imprinted = permanent.getImprinted(); Permanent permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (imprinted.size() > 0) { if (permanent != null) {
Card imprintedCard = game.getCard(imprinted.get(0)); List<UUID> imprinted = permanent.getImprinted();
imprintedCard.setFaceDown(false, game); if (imprinted.size() > 0) {
if (imprintedCard.getCardType().contains(CardType.CREATURE)) { Card imprintedCard = game.getCard(imprinted.get(0));
imprintedCard.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), source.getControllerId()); imprintedCard.setFaceDown(false, game);
if (imprintedCard.getCardType().contains(CardType.CREATURE)) {
controller.moveCards(imprintedCard, Zone.BATTLEFIELD, source, game);
}
} }
} }
return true;
} }
return false;
return true;
} }
@Override @Override

View file

@ -25,14 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.sets.scarsofmirrodin; package mage.sets.scarsofmirrodin;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -41,6 +36,10 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.IntimidateAbility; import mage.abilities.keyword.IntimidateAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.Filter; import mage.filter.Filter;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
@ -57,7 +56,7 @@ import mage.target.common.TargetCardInOpponentsGraveyard;
*/ */
public class GethLordOfTheVault extends CardImpl { public class GethLordOfTheVault extends CardImpl {
public GethLordOfTheVault (UUID ownerId) { public GethLordOfTheVault(UUID ownerId) {
super(ownerId, 64, "Geth, Lord of the Vault", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{4}{B}{B}"); super(ownerId, 64, "Geth, Lord of the Vault", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{4}{B}{B}");
this.expansionSetCode = "SOM"; this.expansionSetCode = "SOM";
this.supertype.add("Legendary"); this.supertype.add("Legendary");
@ -82,15 +81,15 @@ public class GethLordOfTheVault extends CardImpl {
ability.getTargets().clear(); ability.getTargets().clear();
FilterCard filter = new FilterCard(new StringBuilder("artifact or creature card with converted mana cost ").append(xValue).append(" from an opponent's graveyard").toString()); FilterCard filter = new FilterCard(new StringBuilder("artifact or creature card with converted mana cost ").append(xValue).append(" from an opponent's graveyard").toString());
filter.add(Predicates.or( filter.add(Predicates.or(
new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE))); new CardTypePredicate(CardType.CREATURE)));
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, xValue)); filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, xValue));
Target target = new TargetCardInOpponentsGraveyard(filter); Target target = new TargetCardInOpponentsGraveyard(filter);
ability.addTarget(target); ability.addTarget(target);
} }
} }
public GethLordOfTheVault (final GethLordOfTheVault card) { public GethLordOfTheVault(final GethLordOfTheVault card) {
super(card); super(card);
} }
@ -100,6 +99,7 @@ public class GethLordOfTheVault extends CardImpl {
} }
} }
class GethLordOfTheVaultEffect extends OneShotEffect { class GethLordOfTheVaultEffect extends OneShotEffect {
public GethLordOfTheVaultEffect() { public GethLordOfTheVaultEffect() {
@ -113,15 +113,19 @@ class GethLordOfTheVaultEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Card card = game.getCard(getTargetPointer().getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId());
if (card != null) { if (controller != null) {
card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId(), true); Card card = game.getCard(getTargetPointer().getFirst(game, source));
Player player = game.getPlayer(card.getOwnerId()); if (card != null) {
if (player != null) { controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
player.moveCards(player.getLibrary().getTopCards(game, card.getManaCost().convertedManaCost()), Zone.LIBRARY, Zone.GRAVEYARD, source, game); Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
player.moveCards(player.getLibrary().getTopCards(game, card.getManaCost().convertedManaCost()), Zone.GRAVEYARD, source, game);
}
} }
return true;
} }
return true; return false;
} }
@Override @Override

View file

@ -113,18 +113,8 @@ class NimDeathmantleTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
// make sure card is on battlefield
UUID sourceId = getSourceId();
if (game.getPermanent(sourceId) == null) {
// or it is being removed
if (game.getLastKnownInformation(sourceId, Zone.BATTLEFIELD) == null) {
return false;
}
}
ZoneChangeEvent zEvent = (ZoneChangeEvent) event; ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Permanent permanent = zEvent.getTarget(); Permanent permanent = zEvent.getTarget();
if (permanent != null if (permanent != null
&& permanent.getControllerId().equals(this.controllerId) && permanent.getControllerId().equals(this.controllerId)
&& zEvent.getToZone() == Zone.GRAVEYARD && zEvent.getToZone() == Zone.GRAVEYARD
@ -159,29 +149,28 @@ class NimDeathmantleEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Permanent equipment = game.getPermanent(source.getSourceId()); Permanent equipment = game.getPermanent(source.getSourceId());
if (player != null && equipment != null) { if (controller != null && equipment != null) {
if (player.chooseUse(Outcome.Benefit, equipment.getName() + " - Pay " + cost.getText() + "?", source, game)) { if (controller.chooseUse(Outcome.Benefit, equipment.getName() + " - Pay " + cost.getText() + "?", source, game)) {
cost.clearPaid(); cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) { if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
UUID target = targetPointer.getFirst(game, source); UUID target = targetPointer.getFirst(game, source);
if (target != null && equipment != null) { if (target != null) {
Card card = game.getCard(target); Card card = game.getCard(target);
// check if it's still in graveyard // check if it's still in graveyard
if (card != null && game.getState().getZone(card.getId()).equals(Zone.GRAVEYARD)) { if (card != null && game.getState().getZone(card.getId()).equals(Zone.GRAVEYARD)) {
Player owner = game.getPlayer(card.getOwnerId()); if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
if (card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId())) {
Permanent permanent = game.getPermanent(card.getId()); Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) { if (permanent != null) {
permanent.addAttachment(equipment.getId(), game); permanent.addAttachment(equipment.getId(), game);
return true;
} }
} }
} }
} }
} }
} }
return true;
} }
return false; return false;

View file

@ -115,9 +115,9 @@ public class ShapeAnew extends CardImpl {
} }
targetController.revealCards(sourcePermanent.getIdName(), revealed, game); targetController.revealCards(sourcePermanent.getIdName(), revealed, game);
if (artifactCard != null) { if (artifactCard != null) {
artifactCard.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), targetController.getId()); targetController.moveCards(artifactCard, Zone.BATTLEFIELD, source, game);
} }
targetController.moveCards(nonArtifactCards, null, Zone.LIBRARY, source, game); targetController.putCardsOnTopOfLibrary(nonArtifactCards, game, source, false);
targetController.shuffleLibrary(game); targetController.shuffleLibrary(game);
return true; return true;
} }

View file

@ -34,7 +34,6 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CastSourceTriggeredAbility; import mage.abilities.effects.common.CastSourceTriggeredAbility;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.HasteAbility; import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
@ -106,10 +105,7 @@ class DemigodOfRevengeReturnEffect extends OneShotEffect {
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) {
for (Card creature : controller.getGraveyard().getCards(filter, game)) { return controller.moveCards(controller.getGraveyard().getCards(filter, game), Zone.BATTLEFIELD, source, game);
creature.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId());
}
return true;
} }
return false; return false;
} }

View file

@ -28,16 +28,18 @@
package mage.sets.shardsofalara; package mage.sets.shardsofalara;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.NamePredicate; import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game; import mage.game.Game;
@ -56,7 +58,6 @@ public class ClarionUltimatum extends CardImpl {
super(ownerId, 163, "Clarion Ultimatum", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{G}{G}{W}{W}{W}{U}{U}"); super(ownerId, 163, "Clarion Ultimatum", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{G}{G}{W}{W}{W}{U}{U}");
this.expansionSetCode = "ALA"; this.expansionSetCode = "ALA";
// Choose five permanents you control. For each of those permanents, you may search your library for a card with the same name as that permanent. Put those cards onto the battlefield tapped, then shuffle your library. // Choose five permanents you control. For each of those permanents, you may search your library for a card with the same name as that permanent. Put those cards onto the battlefield tapped, then shuffle your library.
this.getSpellAbility().addEffect(new ClarionUltimatumEffect()); this.getSpellAbility().addEffect(new ClarionUltimatumEffect());
} }
@ -90,32 +91,28 @@ class ClarionUltimatumEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
int permanentsCount = game.getBattlefield().getAllActivePermanents(source.getControllerId()).size(); int permanentsCount = game.getBattlefield().getAllActivePermanents(source.getControllerId()).size();
if (player == null || permanentsCount < 1) { if (controller == null || permanentsCount < 1) {
return false; return false;
} }
TargetControlledPermanent permanentsTarget = new TargetControlledPermanent(Math.min(permanentsCount, 5)); TargetControlledPermanent permanentsTarget = new TargetControlledPermanent(Math.min(permanentsCount, 5));
player.choose(Outcome.Benefit, permanentsTarget, source.getSourceId(), game); controller.choose(Outcome.Benefit, permanentsTarget, source.getSourceId(), game);
List<Card> chosenCards = new ArrayList<Card>(); Set<Card> chosenCards = new LinkedHashSet<>();
List<String> namesFiltered = new ArrayList<String>(); List<String> namesFiltered = new ArrayList<>();
List<UUID> permanents = permanentsTarget.getTargets(); List<UUID> permanents = permanentsTarget.getTargets();
for (UUID permanentId : permanents) { for (UUID permanentId : permanents) {
Permanent permanent = game.getPermanent(permanentId); Permanent permanent = game.getPermanent(permanentId);
final String cardName = permanent.getName(); final String cardName = permanent.getName();
if (!namesFiltered.contains(cardName)) { if (!namesFiltered.contains(cardName)) {
StringBuilder sb = new StringBuilder(); if (controller.chooseUse(Outcome.PutCardInPlay, "Search for " + cardName + " in your library?", source, game)) {
sb.append("Search for ").append(cardName).append(" in your library?");
if (player.chooseUse(Outcome.PutCardInPlay, sb.toString(), source, game)) {
FilterCard filter = new FilterCard("card named " + cardName); FilterCard filter = new FilterCard("card named " + cardName);
filter.add(new NamePredicate(cardName)); filter.add(new NamePredicate(cardName));
TargetCardInLibrary target = new TargetCardInLibrary(filter); TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (controller.searchLibrary(target, game)) {
if (player.searchLibrary(target, game)) { Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) { if (card != null) {
chosenCards.add(card); chosenCards.add(card);
} }
@ -126,14 +123,8 @@ class ClarionUltimatumEffect extends OneShotEffect {
} }
} }
for (Card card : chosenCards) { controller.moveCards(chosenCards, Zone.BATTLEFIELD, source, game, true, false, false, null);
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId()); controller.shuffleLibrary(game);
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
permanent.setTapped(true);
}
}
player.shuffleLibrary(game);
return true; return true;
} }
} }

View file

@ -104,7 +104,7 @@ class PrinceOfThrallsTriggeredAbility extends TriggeredAbilityImpl {
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (game.getOpponents(this.getControllerId()).contains(permanent.getControllerId())) { if (game.getOpponents(this.getControllerId()).contains(permanent.getControllerId())) {
for (Effect effect : getEffects()) { for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId(), game.getState().getZoneChangeCounter(event.getTargetId())));
} }
return true; return true;
} }
@ -137,18 +137,21 @@ class PrinceOfThrallsEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(targetPointer.getFirst(game, source)); Card card = game.getCard(targetPointer.getFirst(game, source));
Permanent permanent = (Permanent) game.getLastKnownInformation(card.getId(), Zone.BATTLEFIELD); Permanent permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
Player opponent = game.getPlayer(permanent.getControllerId()); if (controller != null && card != null && permanent != null) {
if (opponent != null && card != null && permanent != null && source.getControllerId() != null) { Player opponent = game.getPlayer(permanent.getControllerId());
PayLifeCost cost = new PayLifeCost(3); if (opponent != null) {
if (opponent.chooseUse(Outcome.Neutral, cost.getText() + " or " + permanent.getName() + " comes back into the battlefield under opponents control", source, game)) { PayLifeCost cost = new PayLifeCost(3);
cost.clearPaid(); if (opponent.chooseUse(Outcome.Neutral, cost.getText() + " or " + card.getLogName() + " comes back into the battlefield under opponents control", source, game)) {
if (cost.pay(source, game, source.getSourceId(), opponent.getId(), true)) { cost.clearPaid();
return true; if (cost.pay(source, game, source.getSourceId(), opponent.getId(), true)) {
return true;
}
} }
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} }
card.putOntoBattlefield(game, Zone.GRAVEYARD, id, source.getControllerId());
return true; return true;
} }
return false; return false;

View file

@ -29,22 +29,21 @@ package mage.sets.shardsofalara;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility; import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.game.ExileZone; import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player;
/** /**
* *
@ -95,7 +94,7 @@ class ExileAllEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(new FilterLandPermanent(), source.getControllerId(), source.getSourceId(), game); List<Permanent> permanents = game.getBattlefield().getActivePermanents(new FilterLandPermanent(), source.getControllerId(), source.getSourceId(), game);
for (Permanent permanent: permanents) { for (Permanent permanent : permanents) {
permanent.moveToExile(source.getSourceId(), "Realm Razer", source.getSourceId(), game); permanent.moveToExile(source.getSourceId(), "Realm Razer", source.getSourceId(), game);
} }
return true; return true;
@ -103,7 +102,6 @@ class ExileAllEffect extends OneShotEffect {
} }
class RealmRazerEffect extends OneShotEffect { class RealmRazerEffect extends OneShotEffect {
public RealmRazerEffect() { public RealmRazerEffect() {
@ -122,17 +120,14 @@ class RealmRazerEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
ExileZone exZone = game.getExile().getExileZone(source.getSourceId()); Player controller = game.getPlayer(source.getControllerId());
if (exZone != null) { if (controller != null) {
for (Card card : exZone.getCards(game)) { ExileZone exZone = game.getExile().getExileZone(source.getSourceId());
if (card != null) { if (exZone != null) {
if(card.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), card.getOwnerId())){ return controller.moveCards(exZone.getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
game.getPermanent(card.getId()).setTapped(true);
}
}
} }
return true; return true;
} }
return false; return false;
} }
} }

View file

@ -57,20 +57,24 @@ import mage.target.common.TargetControlledCreaturePermanent;
/** /**
* *
* Once you announce youre casting Rescue from the Underworld, no player may attempt to * Once you announce youre casting Rescue from the Underworld, no player may
* stop you from casting the spell by removing the creature you want to sacrifice. * attempt to stop you from casting the spell by removing the creature you want
* to sacrifice.
* *
* If you sacrifice a creature token to cast Rescue from the Underworld, it wont return * If you sacrifice a creature token to cast Rescue from the Underworld, it
* to the battlefield, although the target creature card will. * wont return to the battlefield, although the target creature card will.
* *
* If either the sacrificed creature or the target creature card leaves the graveyard * If either the sacrificed creature or the target creature card leaves the
* before the delayed triggered ability resolves during your next upkeep, it wont return. * graveyard before the delayed triggered ability resolves during your next
* upkeep, it wont return.
* *
* However, if the sacrificed creature is put into another public zone instead of the graveyard, * However, if the sacrificed creature is put into another public zone instead
* perhaps because its your commander or because of another replacement effect, it will return * of the graveyard, perhaps because its your commander or because of another
* to the battlefield from the zone it went to. * replacement effect, it will return to the battlefield from the zone it went
* to.
* *
* Rescue from the Underworld is exiled as it resolves, not later as its delayed trigger resolves. * Rescue from the Underworld is exiled as it resolves, not later as its delayed
* trigger resolves.
* *
* *
* @author LevelX2 * @author LevelX2
@ -81,9 +85,8 @@ public class RescueFromTheUnderworld extends CardImpl {
super(ownerId, 102, "Rescue from the Underworld", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{4}{B}"); super(ownerId, 102, "Rescue from the Underworld", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{4}{B}");
this.expansionSetCode = "THS"; this.expansionSetCode = "THS";
// As an additional cost to cast Rescue from the Underworld, sacrifice a creature. // As an additional cost to cast Rescue from the Underworld, sacrifice a creature.
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(1,1,new FilterControlledCreaturePermanent("a creature"), false))); this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent("a creature"), false)));
// Choose target creature card in your graveyard. Return that card and the sacrificed card to the battlefield under your control at the beginning of your next upkeep. Exile Rescue from the Underworld. // Choose target creature card in your graveyard. Return that card and the sacrificed card to the battlefield under your control at the beginning of your next upkeep. Exile Rescue from the Underworld.
this.getSpellAbility().addEffect(new RescueFromTheUnderworldTextEffect()); this.getSpellAbility().addEffect(new RescueFromTheUnderworldTextEffect());
@ -151,15 +154,15 @@ class RescueFromTheUnderworldCreateDelayedTriggeredAbilityEffect extends OneShot
delayedAbility.setControllerId(source.getControllerId()); delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game); delayedAbility.setSourceObject(source.getSourceObject(game), game);
delayedAbility.getTargets().addAll(source.getTargets()); delayedAbility.getTargets().addAll(source.getTargets());
for(Effect effect : delayedAbility.getEffects()) { for (Effect effect : delayedAbility.getEffects()) {
effect.getTargetPointer().init(game, source); effect.getTargetPointer().init(game, source);
} }
// add the sacrificed creature as target // add the sacrificed creature as target
for (Cost cost :source.getCosts()) { for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) { if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacCost = (SacrificeTargetCost) cost; SacrificeTargetCost sacCost = (SacrificeTargetCost) cost;
TargetCardInGraveyard target = new TargetCardInGraveyard(); TargetCardInGraveyard target = new TargetCardInGraveyard();
for(Permanent permanent : sacCost.getPermanents()) { for (Permanent permanent : sacCost.getPermanents()) {
target.add(permanent.getId(), game); target.add(permanent.getId(), game);
delayedAbility.getTargets().add(target); delayedAbility.getTargets().add(target);
} }
@ -214,20 +217,12 @@ class RescueFromTheUnderworldDelayedTriggeredAbility extends DelayedTriggeredAbi
class RescueFromTheUnderworldReturnEffect extends OneShotEffect { class RescueFromTheUnderworldReturnEffect extends OneShotEffect {
private boolean tapped;
public RescueFromTheUnderworldReturnEffect() { public RescueFromTheUnderworldReturnEffect() {
this(false);
}
public RescueFromTheUnderworldReturnEffect(boolean tapped) {
super(Outcome.PutCreatureInPlay); super(Outcome.PutCreatureInPlay);
this.tapped = tapped;
} }
public RescueFromTheUnderworldReturnEffect(final RescueFromTheUnderworldReturnEffect effect) { public RescueFromTheUnderworldReturnEffect(final RescueFromTheUnderworldReturnEffect effect) {
super(effect); super(effect);
this.tapped = effect.tapped;
} }
@Override @Override
@ -237,39 +232,36 @@ class RescueFromTheUnderworldReturnEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
boolean result = false; Player controller = game.getPlayer(source.getControllerId());
// Target card comes only back if in graveyard if (controller != null) {
for (UUID targetId: getTargetPointer().getTargets(game, source)) { // Target card comes only back if in graveyard
Card card = game.getCard(targetId); for (UUID targetId : getTargetPointer().getTargets(game, source)) {
if (card != null) { Card card = game.getCard(targetId);
Player player = game.getPlayer(card.getOwnerId()); if (card != null) {
if (player != null) { controller.moveCards(card, Zone.BATTLEFIELD, source, game);
if(card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId(), tapped)){
result = true;
}
} }
} }
} // However, if the sacrificed creature is put into another public zone instead of the graveyard,
// However, if the sacrificed creature is put into another public zone instead of the graveyard, // perhaps because its your commander or because of another replacement effect, it will return
// perhaps because its your commander or because of another replacement effect, it will return // to the battlefield from the zone it went to.
// to the battlefield from the zone it went to. if (source.getTargets().get(1) != null) {
if (source.getTargets().get(1) != null) { for (UUID targetId : ((Target) source.getTargets().get(1)).getTargets()) {
for (UUID targetId: ((Target) source.getTargets().get(1)).getTargets()) { Card card = game.getCard(targetId);
Card card = game.getCard(targetId); if (card != null && !card.isFaceDown(game)) {
if (card != null && !card.isFaceDown(game)) { Player player = game.getPlayer(card.getOwnerId());
Player player = game.getPlayer(card.getOwnerId()); if (player != null) {
if (player != null) { Zone currentZone = game.getState().getZone(card.getId());
Zone currentZone = game.getState().getZone(card.getId()); if (currentZone.equals(Zone.COMMAND) || currentZone.equals(Zone.GRAVEYARD) || currentZone.equals(Zone.EXILED)) {
if (currentZone.equals(Zone.COMMAND) || currentZone.equals(Zone.GRAVEYARD) || currentZone.equals(Zone.EXILED)) { return player.moveCards(card, Zone.BATTLEFIELD, source, game);
if(card.putOntoBattlefield(game, currentZone, source.getSourceId(), source.getControllerId(), false)){
result = true;
} }
} }
} }
} }
} }
return true;
} }
return result; return false;
} }
} }

View file

@ -52,6 +52,7 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate; import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
@ -116,17 +117,19 @@ class LimDulTheNecromancerEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Card card = game.getCard(targetPointer.getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId());
if (card != null) { if (controller != null) {
Zone currentZone = game.getState().getZone(card.getId()); Card card = game.getCard(targetPointer.getFirst(game, source));
if (card.putOntoBattlefield(game, currentZone, source.getSourceId(), source.getControllerId()) if (card != null) {
&& card.getCardType().contains(CardType.CREATURE)) { if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)
Permanent creature = game.getPermanent(card.getId()); && card.getCardType().contains(CardType.CREATURE)) {
ContinuousEffect effect = new AddCardSubTypeTargetEffect("Zombie", Duration.WhileOnBattlefield); Permanent creature = game.getPermanent(card.getId());
effect.setTargetPointer(new FixedTarget(creature.getId())); ContinuousEffect effect = new AddCardSubTypeTargetEffect("Zombie", Duration.WhileOnBattlefield);
game.addEffect(effect, source); effect.setTargetPointer(new FixedTarget(creature.getId()));
return true; game.addEffect(effect, source);
}
} }
return true;
} }
return false; return false;
} }

View file

@ -62,7 +62,7 @@ public class NorwoodPriestess extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// {tap}: You may put a green creature card from your hand onto the battlefield. Activate this ability only during your turn, before attackers are declared. // {tap}: You may put a green creature card from your hand onto the battlefield. Activate this ability only during your turn, before attackers are declared.
Ability ability = new ActivateIfConditionActivatedAbility(Zone.BATTLEFIELD, Ability ability = new ActivateIfConditionActivatedAbility(Zone.BATTLEFIELD,
new NorwoodPriestessEffect(), new TapSourceCost(), MyTurnBeforeAttackersDeclaredCondition.getInstance()); new NorwoodPriestessEffect(), new TapSourceCost(), MyTurnBeforeAttackersDeclaredCondition.getInstance());
this.addAbility(ability); this.addAbility(ability);
} }
@ -80,9 +80,9 @@ public class NorwoodPriestess extends CardImpl {
class NorwoodPriestessEffect extends OneShotEffect { class NorwoodPriestessEffect extends OneShotEffect {
private static final String choiceText = "Put a green creature card from your hand onto the battlefield?"; private static final String choiceText = "Put a green creature card from your hand onto the battlefield?";
private static final FilterCreatureCard filter = new FilterCreatureCard("a green creature card"); private static final FilterCreatureCard filter = new FilterCreatureCard("a green creature card");
static { static {
filter.add(new ColorPredicate(ObjectColor.GREEN)); filter.add(new ColorPredicate(ObjectColor.GREEN));
} }
@ -103,19 +103,18 @@ class NorwoodPriestessEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (player == null || !player.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) { if (controller == null || !controller.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) {
return false; return false;
} }
TargetCardInHand target = new TargetCardInHand(filter); TargetCardInHand target = new TargetCardInHand(filter);
if (player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
if (card != null) { if (card != null) {
card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), source.getControllerId()); return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
return true;
} }
} }
return false; return false;
} }
} }

View file

@ -44,6 +44,7 @@ import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.stack.Spell; import mage.game.stack.Spell;
import mage.game.stack.StackObject; import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetSpell; import mage.target.TargetSpell;
/** /**
@ -99,24 +100,27 @@ class DesertionEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
UUID objectId = source.getFirstTarget(); UUID objectId = source.getFirstTarget();
UUID sourceId = source.getSourceId(); UUID sourceId = source.getSourceId();
Player controller = game.getPlayer(source.getControllerId());
StackObject stackObject = game.getStack().getStackObject(objectId); if (controller != null) {
if (stackObject != null && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, objectId, sourceId, stackObject.getControllerId()))) { StackObject stackObject = game.getStack().getStackObject(objectId);
if (stackObject instanceof Spell) { if (stackObject != null && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, objectId, sourceId, stackObject.getControllerId()))) {
game.rememberLKI(objectId, Zone.STACK, (Spell) stackObject); if (stackObject instanceof Spell) {
game.getStack().remove(stackObject); game.rememberLKI(objectId, Zone.STACK, (Spell) stackObject);
if (!((Spell) stackObject).isCopiedSpell() && filter.match(stackObject, source.getSourceId(), source.getControllerId(), game)) { game.getStack().remove(stackObject);
MageObject card = game.getObject(stackObject.getSourceId()); if (!((Spell) stackObject).isCopiedSpell() && filter.match(stackObject, source.getSourceId(), source.getControllerId(), game)) {
if (card instanceof Card) { MageObject card = game.getObject(stackObject.getSourceId());
((Card) card).putOntoBattlefield(game, Zone.STACK, source.getSourceId(), source.getControllerId()); if (card instanceof Card) {
controller.moveCards((Card) card, Zone.BATTLEFIELD, source, game);
}
} else {
stackObject.counter(sourceId, game);
} }
} else { game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, objectId, sourceId, stackObject.getControllerId()));
stackObject.counter(sourceId, game); return true;
} }
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, objectId, sourceId, stackObject.getControllerId()));
return true;
} }
} }
return false; return false;
} }

View file

@ -28,9 +28,6 @@
package mage.sets.worldwake; package mage.sets.worldwake;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -38,7 +35,9 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.CardTypePredicate;
@ -96,32 +95,30 @@ class AgadeemOccultistEffect 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 you = game.getPlayer(source.getControllerId());
int allycount = 0; int allycount = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
if (permanent.hasSubtype("Ally")) { if (permanent.hasSubtype("Ally")) {
allycount++; allycount++;
} }
} }
FilterCard filter = new FilterCard("creature card in an opponent's graveyard"); FilterCard filter = new FilterCard("creature card in an opponent's graveyard");
filter.add(new CardTypePredicate(CardType.CREATURE)); filter.add(new CardTypePredicate(CardType.CREATURE));
TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(1, 1, filter); TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(1, 1, filter);
if (you != null) { if (controller != null) {
if (target.canChoose(source.getControllerId(), game) if (target.canChoose(source.getControllerId(), game)
&& you.choose(Outcome.GainControl, target, source.getSourceId(), game)) { && controller.choose(Outcome.GainControl, target, source.getSourceId(), game)) {
if (!target.getTargets().isEmpty()) { if (!target.getTargets().isEmpty()) {
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
if (card != null) { if (card != null) {
if (card.getManaCost().convertedManaCost() <= allycount) { if (card.getManaCost().convertedManaCost() <= allycount) {
card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId()); return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
return true;
} }
} }
} }
} }
return true;
} }
return false; return false;
} }

View file

@ -29,10 +29,6 @@ package mage.sets.zendikar;
import java.util.UUID; import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AttacksAttachedTriggeredAbility; import mage.abilities.common.AttacksAttachedTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
@ -42,6 +38,10 @@ import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
@ -56,9 +56,9 @@ public class ExplorersScope extends CardImpl {
this.expansionSetCode = "ZEN"; this.expansionSetCode = "ZEN";
this.subtype.add("Equipment"); this.subtype.add("Equipment");
// Whenever equipped creature attacks, look at the top card of your library. If it's a land card, you may put it onto the battlefield tapped. // Whenever equipped creature attacks, look at the top card of your library. If it's a land card, you may put it onto the battlefield tapped.
this.addAbility(new AttacksAttachedTriggeredAbility(new ExplorersScopeEffect())); this.addAbility(new AttacksAttachedTriggeredAbility(new ExplorersScopeEffect()));
// Equip ({1}: Attach to target creature you control. Equip only as a sorcery.) // Equip ({1}: Attach to target creature you control. Equip only as a sorcery.)
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(1))); this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(1)));
} }
@ -105,7 +105,7 @@ class ExplorersScopeEffect extends OneShotEffect {
if (card.getCardType().contains(CardType.LAND)) { if (card.getCardType().contains(CardType.LAND)) {
String message = "Put " + card.getLogName() + " onto the battlefield tapped?"; String message = "Put " + card.getLogName() + " onto the battlefield tapped?";
if (controller.chooseUse(Outcome.PutLandInPlay, message, source, game)) { if (controller.chooseUse(Outcome.PutLandInPlay, message, source, game)) {
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId(), true); controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
} }
} }
} }

View file

@ -68,7 +68,6 @@ public class Gigantiform extends CardImpl {
this.expansionSetCode = "ZEN"; this.expansionSetCode = "ZEN";
this.subtype.add("Aura"); this.subtype.add("Aura");
// Kicker {4} // Kicker {4}
this.addAbility(new KickerAbility("{4}")); this.addAbility(new KickerAbility("{4}"));
@ -143,14 +142,14 @@ class GigantiformEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
TargetCardInLibrary target = new TargetCardInLibrary(filter); TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player != null && player.searchLibrary(target, game)) { if (controller != null && controller.searchLibrary(target, game)) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game); Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) { if (card != null) {
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId()); controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} }
player.shuffleLibrary(game); controller.shuffleLibrary(game);
return true; return true;
} }
return false; return false;

View file

@ -28,11 +28,6 @@
package mage.sets.zendikar; package mage.sets.zendikar;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.common.SpellCastControllerTriggeredAbility;
@ -42,6 +37,10 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
@ -61,6 +60,7 @@ import mage.target.common.TargetControlledCreaturePermanent;
public class QuestForTheHolyRelic extends CardImpl { public class QuestForTheHolyRelic extends CardImpl {
private static final FilterSpell filter = new FilterSpell("a creature spell"); private static final FilterSpell filter = new FilterSpell("a creature spell");
static { static {
filter.add(new CardTypePredicate(CardType.CREATURE)); filter.add(new CardTypePredicate(CardType.CREATURE));
} }
@ -69,7 +69,6 @@ public class QuestForTheHolyRelic extends CardImpl {
super(ownerId, 33, "Quest for the Holy Relic", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{W}"); super(ownerId, 33, "Quest for the Holy Relic", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{W}");
this.expansionSetCode = "ZEN"; this.expansionSetCode = "ZEN";
// Whenever you cast a creature spell, you may put a quest counter on Quest for the Holy Relic. // Whenever you cast a creature spell, you may put a quest counter on Quest for the Holy Relic.
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.QUEST.createInstance()), filter, true)); this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.QUEST.createInstance()), filter, true));
// Remove five quest counters from Quest for the Holy Relic and sacrifice it: Search your library for an Equipment card, put it onto the battlefield, and attach it to a creature you control. Then shuffle your library. // Remove five quest counters from Quest for the Holy Relic and sacrifice it: Search your library for an Equipment card, put it onto the battlefield, and attach it to a creature you control. Then shuffle your library.
@ -106,28 +105,26 @@ class QuestForTheHolyRelicEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (player == null) { if (controller == null) {
return false; return false;
} }
FilterCard filter = new FilterCard("Equipment"); FilterCard filter = new FilterCard("Equipment");
filter.add(new SubtypePredicate("Equipment")); filter.add(new SubtypePredicate("Equipment"));
TargetCardInLibrary target = new TargetCardInLibrary(filter); TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) { if (controller.searchLibrary(target, game)) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game); Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) { if (card != null && controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
Permanent equipment = game.getPermanent(card.getId()); Permanent equipment = game.getPermanent(card.getId());
Target targetCreature = new TargetControlledCreaturePermanent(); Target targetCreature = new TargetControlledCreaturePermanent();
if (equipment != null && player.choose(Outcome.BoostCreature, targetCreature, source.getSourceId(), game)) { if (equipment != null && controller.choose(Outcome.BoostCreature, targetCreature, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(targetCreature.getFirstTarget()); Permanent permanent = game.getPermanent(targetCreature.getFirstTarget());
permanent.addAttachment(equipment.getId(), game); permanent.addAttachment(equipment.getId(), game);
} }
} }
} }
player.shuffleLibrary(game); controller.shuffleLibrary(game);
return true; return true;
} }
} }

View file

@ -128,6 +128,8 @@ public class CleverImpersonatorTest extends CardTestPlayerBase {
addTarget(playerA, "Clever Impersonator"); addTarget(playerA, "Clever Impersonator");
setChoice(playerA, "Liliana, Defiant Necromancer"); setChoice(playerA, "Liliana, Defiant Necromancer");
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "+2: Each player discards a card");
setStopAt(1, PhaseStep.END_TURN); setStopAt(1, PhaseStep.END_TURN);
execute(); execute();