diff --git a/Mage.Sets/src/mage/sets/antiquities/DrafnasRestoration.java b/Mage.Sets/src/mage/sets/antiquities/DrafnasRestoration.java index 55f990e15d..fc24c4ffcb 100644 --- a/Mage.Sets/src/mage/sets/antiquities/DrafnasRestoration.java +++ b/Mage.Sets/src/mage/sets/antiquities/DrafnasRestoration.java @@ -40,14 +40,11 @@ import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; -import mage.constants.Zone; -import mage.filter.FilterCard; import mage.filter.common.FilterArtifactCard; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.stack.StackObject; import mage.players.Player; -import mage.target.TargetCard; import mage.target.TargetPlayer; import mage.target.common.TargetCardInGraveyard; @@ -135,30 +132,9 @@ class DrafnasRestorationEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Player targetPlayer = game.getPlayer(source.getFirstTarget()); - if (controller != null && targetPlayer != null) { - Cards cards = new CardsImpl(source.getTargets().get(1).getTargets()); // prevent possible ConcurrentModificationException - cards.addAll(source.getTargets().get(1).getTargets()); - if (!cards.isEmpty()) { - TargetCard target = new TargetCard(Zone.PICK, new FilterCard("card to put on the top of the library (last one chosen will be topmost)")); - target.setRequired(true); - while (controller.isInGame() && cards.size() > 1) { - controller.choose(Outcome.Neutral, cards, target, game); - UUID targetId = target.getFirstTarget(); - cards.remove(targetId); - target.clearChosen(); - Card card = targetPlayer.getGraveyard().get(targetId, game); - if (card != null) { - controller.moveCards(card, Zone.GRAVEYARD, Zone.LIBRARY, source, game); - } - } - if (cards.size() == 1) { - Card card = targetPlayer.getGraveyard().get(cards.iterator().next(), game); - if (card != null) { - controller.moveCards(card, Zone.GRAVEYARD, Zone.LIBRARY, source, game); - } - } - } + if (controller != null) { + Cards cards = new CardsImpl(source.getTargets().get(1).getTargets()); + controller.putCardsOnTopOfLibrary(cards, game, source, true); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/onslaught/BlatantThievery.java b/Mage.Sets/src/mage/sets/onslaught/BlatantThievery.java index 512927844e..09586f6108 100644 --- a/Mage.Sets/src/mage/sets/onslaught/BlatantThievery.java +++ b/Mage.Sets/src/mage/sets/onslaught/BlatantThievery.java @@ -30,17 +30,21 @@ package mage.sets.onslaught; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.SpellAbility; -import mage.abilities.effects.Effect; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.continuous.GainControlTargetEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; +import mage.constants.Outcome; import mage.constants.Rarity; import mage.filter.FilterPermanent; import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.players.Player; +import mage.target.Target; import mage.target.TargetPermanent; +import mage.target.targetpointer.FixedTarget; /** * @@ -53,9 +57,7 @@ public class BlatantThievery extends CardImpl { this.expansionSetCode = "ONS"; // For each opponent, gain control of target permanent that player controls. - Effect effect = new GainControlTargetEffect(Duration.EndOfGame); - effect.setText("For each opponent, gain control of target permanent that player controls"); - this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(new BlatantThieveryEffect()); } public BlatantThievery(final BlatantThievery card) { @@ -82,3 +84,30 @@ public class BlatantThievery extends CardImpl { return new BlatantThievery(this); } } + +class BlatantThieveryEffect extends OneShotEffect { + + BlatantThieveryEffect() { + super(Outcome.GainControl); + this.staticText = "For each opponent, gain control of target permanent that player controls"; + } + + BlatantThieveryEffect(final BlatantThieveryEffect effect) { + super(effect); + } + + @Override + public BlatantThieveryEffect copy() { + return new BlatantThieveryEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + for (Target target : source.getTargets()) { + ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame); + effect.setTargetPointer(new FixedTarget(target.getFirstTarget())); + game.addEffect(effect, source); + } + return true; + } +}