Fixed Blatant Thievery and Drafna's Restoration.

This commit is contained in:
emerald000 2015-10-05 11:31:38 -04:00
parent 9072fb95d7
commit 65e7527b2f
2 changed files with 36 additions and 31 deletions

View file

@ -40,14 +40,11 @@ import mage.cards.CardsImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterArtifactCard; import mage.filter.common.FilterArtifactCard;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.stack.StackObject; import mage.game.stack.StackObject;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import mage.target.common.TargetCardInGraveyard; import mage.target.common.TargetCardInGraveyard;
@ -135,30 +132,9 @@ class DrafnasRestorationEffect 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());
Player targetPlayer = game.getPlayer(source.getFirstTarget()); if (controller != null) {
if (controller != null && targetPlayer != null) { Cards cards = new CardsImpl(source.getTargets().get(1).getTargets());
Cards cards = new CardsImpl(source.getTargets().get(1).getTargets()); // prevent possible ConcurrentModificationException controller.putCardsOnTopOfLibrary(cards, game, source, true);
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);
}
}
}
return true; return true;
} }
return false; return false;

View file

@ -30,17 +30,21 @@ package mage.sets.onslaught;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; 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.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.Target;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -53,9 +57,7 @@ public class BlatantThievery extends CardImpl {
this.expansionSetCode = "ONS"; this.expansionSetCode = "ONS";
// For each opponent, gain control of target permanent that player controls. // For each opponent, gain control of target permanent that player controls.
Effect effect = new GainControlTargetEffect(Duration.EndOfGame); this.getSpellAbility().addEffect(new BlatantThieveryEffect());
effect.setText("For each opponent, gain control of target permanent that player controls");
this.getSpellAbility().addEffect(effect);
} }
public BlatantThievery(final BlatantThievery card) { public BlatantThievery(final BlatantThievery card) {
@ -82,3 +84,30 @@ public class BlatantThievery extends CardImpl {
return new BlatantThievery(this); 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;
}
}