* Some rework of card movement.

This commit is contained in:
LevelX2 2015-08-04 17:54:17 +02:00
parent 96bbe01aae
commit a644e66b7f
83 changed files with 798 additions and 816 deletions

View file

@ -28,6 +28,7 @@
package mage.sets.apocalypse; package mage.sets.apocalypse;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
@ -51,9 +52,10 @@ import mage.target.common.TargetCardInLibrary;
* @author emerald000 * @author emerald000
*/ */
public class WildResearch extends CardImpl { public class WildResearch extends CardImpl {
private static final FilterCard filterEnchantment = new FilterCard("enchantment card"); private static final FilterCard filterEnchantment = new FilterCard("enchantment card");
private static final FilterCard filterInstant = new FilterCard("instant card"); private static final FilterCard filterInstant = new FilterCard("instant card");
static { static {
filterEnchantment.add(new CardTypePredicate(CardType.ENCHANTMENT)); filterEnchantment.add(new CardTypePredicate(CardType.ENCHANTMENT));
filterInstant.add(new CardTypePredicate(CardType.INSTANT)); filterInstant.add(new CardTypePredicate(CardType.INSTANT));
@ -65,7 +67,7 @@ public class WildResearch extends CardImpl {
// {1}{W}: Search your library for an enchantment card and reveal that card. Put it into your hand, then discard a card at random. Then shuffle your library. // {1}{W}: Search your library for an enchantment card and reveal that card. Put it into your hand, then discard a card at random. Then shuffle your library.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WildResearchEffect(filterEnchantment), new ManaCostsImpl<>("{1}{W}"))); this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WildResearchEffect(filterEnchantment), new ManaCostsImpl<>("{1}{W}")));
// {1}{U}: Search your library for an instant card and reveal that card. Put it into your hand, then discard a card at random. Then shuffle your library. // {1}{U}: Search your library for an instant card and reveal that card. Put it into your hand, then discard a card at random. Then shuffle your library.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WildResearchEffect(filterInstant), new ManaCostsImpl<>("{1}{U}"))); this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WildResearchEffect(filterInstant), new ManaCostsImpl<>("{1}{U}")));
@ -82,43 +84,44 @@ public class WildResearch extends CardImpl {
} }
class WildResearchEffect extends OneShotEffect { class WildResearchEffect extends OneShotEffect {
protected final FilterCard filter; protected final FilterCard filter;
WildResearchEffect(FilterCard filter) { WildResearchEffect(FilterCard filter) {
super(Outcome.DrawCard); super(Outcome.DrawCard);
this.staticText = "Search your library for an " + filter.getMessage() + " and reveal that card. Put it into your hand, then discard a card at random. Then shuffle your library."; this.staticText = "Search your library for an " + filter.getMessage() + " and reveal that card. Put it into your hand, then discard a card at random. Then shuffle your library.";
this.filter = filter; this.filter = filter;
} }
WildResearchEffect(final WildResearchEffect effect) { WildResearchEffect(final WildResearchEffect effect) {
super(effect); super(effect);
this.filter = effect.filter; this.filter = effect.filter;
} }
@Override @Override
public WildResearchEffect copy() { public WildResearchEffect copy() {
return new WildResearchEffect(this); return new WildResearchEffect(this);
} }
@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) { MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
TargetCardInLibrary target = new TargetCardInLibrary(filter); TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) { if (controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) { if (target.getTargets().size() > 0) {
Card card = player.getLibrary().remove(target.getFirstTarget(), game); Card card = controller.getLibrary().remove(target.getFirstTarget(), game);
if (card != null) { if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
cards.add(card); cards.add(card);
player.revealCards("Wild Research", cards, game, true); controller.revealCards(sourceObject.getIdName(), cards, game, true);
} }
} }
} }
player.discardOne(true, source, game); controller.discardOne(true, source, game);
player.shuffleLibrary(game); controller.shuffleLibrary(game);
return true; return true;
} }
return false; return false;

View file

@ -25,7 +25,6 @@
* 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.betrayersofkamigawa; package mage.sets.betrayersofkamigawa;
import java.util.UUID; import java.util.UUID;
@ -39,7 +38,6 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect; 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.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
@ -69,7 +67,7 @@ public class QuillmaneBaku extends CardImpl {
this.power = new MageInt(3); this.power = new MageInt(3);
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// Whenever you cast a Spirit or Arcane spell, you may put a ki counter on Skullmane Baku. // Whenever you cast a Spirit or Arcane spell, you may put a ki counter on Skullmane Baku.
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.KI.createInstance()), filter, true)); this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.KI.createInstance()), filter, true));
@ -87,11 +85,11 @@ public class QuillmaneBaku extends CardImpl {
int maxConvManaCost = 0; int maxConvManaCost = 0;
for (Cost cost : ability.getCosts()) { for (Cost cost : ability.getCosts()) {
if (cost instanceof RemoveVariableCountersSourceCost) { if (cost instanceof RemoveVariableCountersSourceCost) {
maxConvManaCost = ((RemoveVariableCountersSourceCost)cost).getAmount(); maxConvManaCost = ((RemoveVariableCountersSourceCost) cost).getAmount();
} }
} }
ability.getTargets().clear(); ability.getTargets().clear();
FilterCreaturePermanent newFilter = new FilterCreaturePermanent("creature with converted mana cost " + maxConvManaCost + " or less"); FilterCreaturePermanent newFilter = new FilterCreaturePermanent("creature with converted mana cost " + maxConvManaCost + " or less");
newFilter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, maxConvManaCost + 1)); newFilter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, maxConvManaCost + 1));
TargetCreaturePermanent target = new TargetCreaturePermanent(newFilter); TargetCreaturePermanent target = new TargetCreaturePermanent(newFilter);
ability.getTargets().add(target); ability.getTargets().add(target);
@ -106,7 +104,7 @@ public class QuillmaneBaku extends CardImpl {
public QuillmaneBaku copy() { public QuillmaneBaku copy() {
return new QuillmaneBaku(this); return new QuillmaneBaku(this);
} }
class QuillmaneBakuReturnEffect extends OneShotEffect { class QuillmaneBakuReturnEffect extends OneShotEffect {
public QuillmaneBakuReturnEffect() { public QuillmaneBakuReturnEffect() {
@ -125,16 +123,15 @@ public class QuillmaneBaku extends CardImpl {
@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;
} }
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source)); Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (permanent != null) { if (permanent != null) {
player.moveCardToHandWithInfo((Card) permanent, source.getSourceId(), game, Zone.BATTLEFIELD); controller.moveCards(permanent, null, Zone.HAND, source, game);
return true;
} }
return false; return true;
} }
} }
} }

View file

@ -27,8 +27,8 @@
*/ */
package mage.sets.bornofthegods; package mage.sets.bornofthegods;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -44,7 +44,6 @@ import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.common.FilterBasicLandCard; import mage.filter.common.FilterBasicLandCard;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
@ -59,7 +58,6 @@ public class Peregrination extends CardImpl {
super(ownerId, 132, "Peregrination", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{3}{G}"); super(ownerId, 132, "Peregrination", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{3}{G}");
this.expansionSetCode = "BNG"; this.expansionSetCode = "BNG";
// Seach your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Shuffle your library, then scry 1. // Seach your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Shuffle your library, then scry 1.
this.getSpellAbility().addEffect(new PeregrinationEffect()); this.getSpellAbility().addEffect(new PeregrinationEffect());
Effect effect = new ScryEffect(1); Effect effect = new ScryEffect(1);
@ -97,36 +95,39 @@ class PeregrinationEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterBasicLandCard()); TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterBasicLandCard());
Player player = game.getPlayer(source.getControllerId()); if (controller.searchLibrary(target, game)) {
if (player.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) { if (target.getTargets().size() > 0) {
Cards revealed = new CardsImpl(); Cards revealed = new CardsImpl();
for (UUID cardId: target.getTargets()) { for (UUID cardId : target.getTargets()) {
Card card = player.getLibrary().getCard(cardId, game); Card card = controller.getLibrary().getCard(cardId, game);
revealed.add(card); revealed.add(card);
} }
player.revealCards("Peregrination", revealed, game); controller.revealCards(sourceObject.getIdName(), revealed, game);
if (target.getTargets().size() == 2) { if (target.getTargets().size() == 2) {
TargetCard target2 = new TargetCard(Zone.PICK, filter); TargetCard target2 = new TargetCard(Zone.LIBRARY, filter);
player.choose(Outcome.Benefit, revealed, target2, game); controller.choose(Outcome.Benefit, revealed, target2, game);
Card card = revealed.get(target2.getFirstTarget(), game); Card card = revealed.get(target2.getFirstTarget(), game);
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
revealed.remove(card); revealed.remove(card);
card = revealed.getCards(game).iterator().next(); card = revealed.getCards(game).iterator().next();
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
} } else if (target.getTargets().size() == 1) {
else if (target.getTargets().size() == 1) {
Card card = revealed.getCards(game).iterator().next(); Card card = revealed.getCards(game).iterator().next();
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
} }
} }
player.shuffleLibrary(game); controller.shuffleLibrary(game);
return true; return true;
} }
player.shuffleLibrary(game); controller.shuffleLibrary(game);
return false; return false;
} }

View file

@ -103,13 +103,13 @@ class SatyrWayfinderEffect extends OneShotEffect {
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getName(), cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, filterPutInHand); TargetCard target = new TargetCard(Zone.LIBRARY, filterPutInHand);
if (properCardFound && if (properCardFound
controller.chooseUse(outcome, "Put a land card into your hand?", source, game) && && controller.chooseUse(outcome, "Put a land card into your hand?", source, game)
controller.choose(Outcome.DrawCard, cards, target, game)) { && controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
if (card != null) { if (card != null) {
cards.remove(card); cards.remove(card);
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
} }
} }

View file

@ -28,6 +28,7 @@
package mage.sets.coldsnap; package mage.sets.coldsnap;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
@ -57,7 +58,7 @@ public class ScryingSheets extends CardImpl {
// {tap}: Add {1} to your mana pool. // {tap}: Add {1} to your mana pool.
this.addAbility(new ColorlessManaAbility()); this.addAbility(new ColorlessManaAbility());
// {1}{snow}, {tap}: Look at the top card of your library. If that card is snow, you may reveal it and put it into your hand. // {1}{snow}, {tap}: Look at the top card of your library. If that card is snow, you may reveal it and put it into your hand.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ScryingSheetsEffect(), new ManaCostsImpl<>("{1}{snow}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ScryingSheetsEffect(), new ManaCostsImpl<>("{1}{snow}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
@ -75,35 +76,35 @@ public class ScryingSheets extends CardImpl {
} }
class ScryingSheetsEffect extends OneShotEffect { class ScryingSheetsEffect extends OneShotEffect {
ScryingSheetsEffect() { ScryingSheetsEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
this.staticText = "Look at the top card of your library. If that card is snow, you may reveal it and put it into your hand"; this.staticText = "Look at the top card of your library. If that card is snow, you may reveal it and put it into your hand";
} }
ScryingSheetsEffect(final ScryingSheetsEffect effect) { ScryingSheetsEffect(final ScryingSheetsEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public ScryingSheetsEffect copy() { public ScryingSheetsEffect copy() {
return new ScryingSheetsEffect(this); return new ScryingSheetsEffect(this);
} }
@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.getLibrary().size() > 0) { MageObject sourceObject = game.getObject(source.getSourceId());
Card card = player.getLibrary().getFromTop(game); if (controller != null && sourceObject != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) { if (card != null) {
CardsImpl cards = new CardsImpl(); CardsImpl cards = new CardsImpl();
cards.add(card); cards.add(card);
player.lookAtCards("Scrying Sheets", cards, game); controller.lookAtCards(sourceObject.getIdName(), cards, game);
if (card.getSupertype().contains("Snow")) { if (card.getSupertype().contains("Snow")) {
if (player.chooseUse(outcome, new StringBuilder("Reveal ").append(card.getName()).append(" and put it into your hand?").toString(), source, game)) { if (controller.chooseUse(outcome, "Reveal " + card.getLogName() + " and put it into your hand?", source, game)) {
card = player.getLibrary().removeFromTop(game); controller.moveCards(card, null, Zone.HAND, source, game);
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.revealCards(sourceObject.getIdName(), cards, game);
player.revealCards("Scrying Sheets", cards, game);
} }
} }
} }

View file

@ -113,22 +113,20 @@ class DesecratorHagEffect extends OneShotEffect {
} }
} }
if (cards.size() == 0) { if (cards.size() == 0) {
return false; return true;
} }
if (cards.size() > 1 if (cards.size() > 1
&& you.choose(Outcome.DrawCard, cards, target, game)) { && you.choose(Outcome.DrawCard, cards, target, game)) {
if (target != null) { if (target != null) {
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
if (card != null) { if (card != null) {
return you.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD); return you.moveCards(card, null, Zone.HAND, source, game);
} }
} }
} else { } else {
for (Card card : cards.getCards(game)) { return you.moveCards(cards, null, Zone.HAND, source, game);
return you.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
}
} }
} }
return false; return false;
} }
} }

View file

@ -27,8 +27,8 @@
*/ */
package mage.sets.commander; package mage.sets.commander;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
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;
@ -57,7 +57,6 @@ public class KodamasReach extends CardImpl {
this.expansionSetCode = "CMD"; this.expansionSetCode = "CMD";
this.subtype.add("Arcane"); this.subtype.add("Arcane");
// Search your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Then shuffle your library. // Search your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Then shuffle your library.
this.getSpellAbility().addEffect(new KodamasReachEffect()); this.getSpellAbility().addEffect(new KodamasReachEffect());
} }
@ -92,43 +91,46 @@ class KodamasReachEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterBasicLandCard()); TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterBasicLandCard());
Player player = game.getPlayer(source.getControllerId()); if (controller.searchLibrary(target, game)) {
if (player.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) { if (target.getTargets().size() > 0) {
Cards revealed = new CardsImpl(); Cards revealed = new CardsImpl();
for (UUID cardId: target.getTargets()) { for (UUID cardId : target.getTargets()) {
Card card = player.getLibrary().getCard(cardId, game); Card card = controller.getLibrary().getCard(cardId, game);
revealed.add(card); revealed.add(card);
} }
player.revealCards("Kodama's Reach", revealed, game); controller.revealCards(sourceObject.getIdName(), revealed, game);
if (target.getTargets().size() == 2) { if (target.getTargets().size() == 2) {
TargetCard target2 = new TargetCard(Zone.PICK, filter); TargetCard target2 = new TargetCard(Zone.PICK, filter);
player.choose(Outcome.Benefit, revealed, target2, game); controller.choose(Outcome.Benefit, revealed, target2, game);
Card card = revealed.get(target2.getFirstTarget(), game); Card card = revealed.get(target2.getFirstTarget(), game);
if (card != null) { if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
revealed.remove(card); revealed.remove(card);
} }
card = revealed.getCards(game).iterator().next(); card = revealed.getCards(game).iterator().next();
if (card != null) { if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
} }
} } else if (target.getTargets().size() == 1) {
else if (target.getTargets().size() == 1) {
Card card = revealed.getCards(game).iterator().next(); Card card = revealed.getCards(game).iterator().next();
if (card != null) { if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
} }
} }
} }
player.shuffleLibrary(game); controller.shuffleLibrary(game);
return true; return true;
} }
player.shuffleLibrary(game); controller.shuffleLibrary(game);
return false; return false;
} }
} }

View file

@ -51,7 +51,6 @@ public class WhirlpoolWhelm extends CardImpl {
super(ownerId, 69, "Whirlpool Whelm", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{U}"); super(ownerId, 69, "Whirlpool Whelm", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{U}");
this.expansionSetCode = "CMD"; this.expansionSetCode = "CMD";
// Clash with an opponent, then return target creature to its owner's hand. If you win, you may put that creature on top of its owner's library instead. // Clash with an opponent, then return target creature to its owner's hand. If you win, you may put that creature on top of its owner's library instead.
this.getSpellAbility().addEffect(new WhirlpoolWhelmEffect()); this.getSpellAbility().addEffect(new WhirlpoolWhelmEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent());
@ -90,15 +89,15 @@ class WhirlpoolWhelmEffect extends OneShotEffect {
if (controller != null) { if (controller != null) {
boolean topOfLibrary = false; boolean topOfLibrary = false;
if (ClashEffect.getInstance().apply(game, source)) { if (ClashEffect.getInstance().apply(game, source)) {
topOfLibrary = controller.chooseUse(outcome, "Put " + creature.getLogName() + " to top of libraray instead?" , source, game); topOfLibrary = controller.chooseUse(outcome, "Put " + creature.getLogName() + " to top of libraray instead?", source, game);
} }
if (topOfLibrary) { if (topOfLibrary) {
controller.moveCardToHandWithInfo(creature, source.getSourceId(), game, Zone.BATTLEFIELD);
} else {
controller.moveCardToLibraryWithInfo(creature, source.getSourceId(), game, Zone.BATTLEFIELD, true, true); controller.moveCardToLibraryWithInfo(creature, source.getSourceId(), game, Zone.BATTLEFIELD, true, true);
} else {
controller.moveCards(creature, null, Zone.HAND, source, game);
} }
return true; return true;
} }
return false; return false;
} }
} }

View file

@ -32,8 +32,8 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardsImpl;
import mage.cards.repository.CardRepository; import mage.cards.repository.CardRepository;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
@ -101,22 +101,17 @@ class GraveSifterEffect extends OneShotEffect {
typeChoice.setChoices(CardRepository.instance.getCreatureTypes()); typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
for (UUID playerId: controller.getInRange()) { for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
typeChoice.clearChoice(); typeChoice.clearChoice();
if (player.choose(outcome, typeChoice, game)) { if (player.choose(outcome, typeChoice, game)) {
game.informPlayers(player.getLogName() + " has chosen: " + typeChoice.getChoice()); game.informPlayers(player.getLogName() + " has chosen: " + typeChoice.getChoice());
FilterCard filter = new FilterCreatureCard("creature cards with creature type " + typeChoice.getChoice()+ " from your graveyard"); FilterCard filter = new FilterCreatureCard("creature cards with creature type " + typeChoice.getChoice() + " from your graveyard");
filter.add(new SubtypePredicate(typeChoice.getChoice())); filter.add(new SubtypePredicate(typeChoice.getChoice()));
Target target = new TargetCardInYourGraveyard(0,Integer.MAX_VALUE, filter); Target target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter);
player.chooseTarget(outcome, target, source, game); player.chooseTarget(outcome, target, source, game);
for (UUID cardId: target.getTargets()) { player.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game);
Card card = game.getCard(cardId);
if (card !=null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
}
}
} }
} }

View file

@ -28,10 +28,6 @@
package mage.sets.conflux; package mage.sets.conflux;
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.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -42,6 +38,10 @@ import mage.abilities.keyword.VigilanceAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
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;
@ -73,7 +73,7 @@ public class SkywardEyeProphets extends CardImpl {
public SkywardEyeProphets copy() { public SkywardEyeProphets copy() {
return new SkywardEyeProphets(this); return new SkywardEyeProphets(this);
} }
public static class SkywardEyeProphetsEffect extends OneShotEffect { public static class SkywardEyeProphetsEffect extends OneShotEffect {
public SkywardEyeProphetsEffect() { public SkywardEyeProphetsEffect() {
@ -108,7 +108,7 @@ public class SkywardEyeProphets extends CardImpl {
if (card.getCardType().contains(CardType.LAND)) { if (card.getCardType().contains(CardType.LAND)) {
return controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); return controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
} else { } else {
return controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
} }
} }
return true; return true;

View file

@ -66,21 +66,21 @@ public class PulseOfTheFields extends CardImpl {
} }
class PulseOfTheFieldsReturnToHandEffect extends OneShotEffect { class PulseOfTheFieldsReturnToHandEffect extends OneShotEffect {
PulseOfTheFieldsReturnToHandEffect() { PulseOfTheFieldsReturnToHandEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
this.staticText = "Then if an opponent has more life than you, return {this} to its owner's hand"; this.staticText = "Then if an opponent has more life than you, return {this} to its owner's hand";
} }
PulseOfTheFieldsReturnToHandEffect(final PulseOfTheFieldsReturnToHandEffect effect) { PulseOfTheFieldsReturnToHandEffect(final PulseOfTheFieldsReturnToHandEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public PulseOfTheFieldsReturnToHandEffect copy() { public PulseOfTheFieldsReturnToHandEffect copy() {
return new PulseOfTheFieldsReturnToHandEffect(this); return new PulseOfTheFieldsReturnToHandEffect(this);
} }
@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());
@ -89,7 +89,7 @@ class PulseOfTheFieldsReturnToHandEffect extends OneShotEffect {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null && player.getLife() > controller.getLife()) { if (player != null && player.getLife() > controller.getLife()) {
Card card = game.getCard(source.getSourceId()); Card card = game.getCard(source.getSourceId());
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.STACK); controller.moveCards(card, null, Zone.HAND, source, game);
return true; return true;
} }
} }

View file

@ -66,21 +66,21 @@ public class PulseOfTheGrid extends CardImpl {
} }
class PulseOfTheGridReturnToHandEffect extends OneShotEffect { class PulseOfTheGridReturnToHandEffect extends OneShotEffect {
PulseOfTheGridReturnToHandEffect() { PulseOfTheGridReturnToHandEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
this.staticText = "Draw two cards, then discard a card. Then if an opponent has more cards in hand than you, return {this} to its owner's hand"; this.staticText = "Draw two cards, then discard a card. Then if an opponent has more cards in hand than you, return {this} to its owner's hand";
} }
PulseOfTheGridReturnToHandEffect(final PulseOfTheGridReturnToHandEffect effect) { PulseOfTheGridReturnToHandEffect(final PulseOfTheGridReturnToHandEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public PulseOfTheGridReturnToHandEffect copy() { public PulseOfTheGridReturnToHandEffect copy() {
return new PulseOfTheGridReturnToHandEffect(this); return new PulseOfTheGridReturnToHandEffect(this);
} }
@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());
@ -89,7 +89,7 @@ class PulseOfTheGridReturnToHandEffect extends OneShotEffect {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null && player.getHand().size() > controller.getHand().size()) { if (player != null && player.getHand().size() > controller.getHand().size()) {
Card card = game.getCard(source.getSourceId()); Card card = game.getCard(source.getSourceId());
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.STACK); controller.moveCards(card, null, Zone.HAND, source, game);
return true; return true;
} }
} }

View file

@ -25,7 +25,6 @@
* 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.darksteel; package mage.sets.darksteel;
import java.util.UUID; import java.util.UUID;
@ -105,7 +104,7 @@ public class SwordOfLightAndShadow extends CardImpl {
// Target may only be added if possible target exists. Else the gain life effect won't trigger, becuase there is no valid target for the // Target may only be added if possible target exists. Else the gain life effect won't trigger, becuase there is no valid target for the
// return to hand ability // return to hand ability
if (controller.getGraveyard().count(new FilterCreatureCard(), ability.getSourceId(), ability.getControllerId(), game) > 0) { if (controller.getGraveyard().count(new FilterCreatureCard(), ability.getSourceId(), ability.getControllerId(), game) > 0) {
ability.addTarget(new TargetCardInYourGraveyard(0,1,new FilterCreatureCard("creature card from your graveyard"))); ability.addTarget(new TargetCardInYourGraveyard(0, 1, new FilterCreatureCard("creature card from your graveyard")));
} }
} }
} }
@ -118,7 +117,7 @@ class SwordOfLightAndShadowAbility extends TriggeredAbilityImpl {
public SwordOfLightAndShadowAbility() { public SwordOfLightAndShadowAbility() {
super(Zone.BATTLEFIELD, new SwordOfLightAndShadowReturnToHandTargetEffect(), false); super(Zone.BATTLEFIELD, new SwordOfLightAndShadowReturnToHandTargetEffect(), false);
this.addEffect(new GainLifeEffect(3)); this.addEffect(new GainLifeEffect(3));
} }
public SwordOfLightAndShadowAbility(final SwordOfLightAndShadowAbility ability) { public SwordOfLightAndShadowAbility(final SwordOfLightAndShadowAbility ability) {
@ -178,8 +177,8 @@ class SwordOfLightAndShadowReturnToHandTargetEffect extends OneShotEffect {
case GRAVEYARD: case GRAVEYARD:
Card card = game.getCard(targetId); Card card = game.getCard(targetId);
if (card != null) { if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD); controller.moveCards(card, null, Zone.HAND, source, game);
} else { } else {
result = false; result = false;
} }
break; break;

View file

@ -29,15 +29,15 @@ package mage.sets.dissension;
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.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.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.cards.SplitCard; import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreatureCard;
import mage.game.Game; import mage.game.Game;
@ -54,9 +54,9 @@ import mage.target.common.TargetCreaturePermanent;
public class RiseFall extends SplitCard { public class RiseFall extends SplitCard {
public RiseFall(UUID ownerId) { public RiseFall(UUID ownerId) {
super(ownerId, 156, "Rise", "Fall", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{U}{B}","{B}{R}", false ); super(ownerId, 156, "Rise", "Fall", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{U}{B}", "{B}{R}", false);
this.expansionSetCode = "DIS"; this.expansionSetCode = "DIS";
// Rise // Rise
// Return target creature card from a graveyard and target creature on the battlefield to their owners' hands. // Return target creature card from a graveyard and target creature on the battlefield to their owners' hands.
getLeftHalfCard().getSpellAbility().addEffect(new RiseEffect()); getLeftHalfCard().getSpellAbility().addEffect(new RiseEffect());
@ -99,14 +99,16 @@ class RiseEffect 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) {
Cards cardsToHand = new CardsImpl();
Card cardInGraveyard = game.getCard(getTargetPointer().getFirst(game, source)); Card cardInGraveyard = game.getCard(getTargetPointer().getFirst(game, source));
if (cardInGraveyard != null) { if (cardInGraveyard != null) {
controller.moveCardToHandWithInfo(cardInGraveyard, source.getSourceId(), game, Zone.GRAVEYARD); cardsToHand.add(cardInGraveyard);
} }
Permanent permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); Permanent permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (permanent != null) { if (permanent != null) {
controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD); cardsToHand.add(permanent);
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true; return true;
} }
return false; return false;
@ -147,7 +149,7 @@ class FallEffect extends OneShotEffect {
cards.add(card); cards.add(card);
} }
targetPlayer.revealCards(sourceObject.getName(), cards, game); targetPlayer.revealCards(sourceObject.getName(), cards, game);
for (Card cardToDiscard: cards.getCards(game)) { for (Card cardToDiscard : cards.getCards(game)) {
if (!cardToDiscard.getCardType().contains(CardType.LAND)) { if (!cardToDiscard.getCardType().contains(CardType.LAND)) {
targetPlayer.discard(cardToDiscard, source, game); targetPlayer.discard(cardToDiscard, source, game);
} }

View file

@ -28,15 +28,14 @@
package mage.sets.dragonsmaze; package mage.sets.dragonsmaze;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
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.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.FilterCreatureCard; import mage.filter.common.FilterCreatureCard;
import mage.game.Game; import mage.game.Game;
@ -55,7 +54,6 @@ public class MorgueBurst extends CardImpl {
super(ownerId, 86, "Morgue Burst", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{4}{B}{R}"); super(ownerId, 86, "Morgue Burst", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{4}{B}{R}");
this.expansionSetCode = "DGM"; this.expansionSetCode = "DGM";
// Return target creature card from your graveyard to your hand. Morgue Burst deals damage to target creature or player equal to the power of the card returned this way. // Return target creature card from your graveyard to your hand. Morgue Burst deals damage to target creature or player equal to the power of the card returned this way.
this.getSpellAbility().addEffect(new MorgueBurstEffect()); this.getSpellAbility().addEffect(new MorgueBurstEffect());
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard"))); this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard")));
@ -93,7 +91,7 @@ class MorgueBurstEffect extends OneShotEffect {
if (card != null) { if (card != null) {
Player player = game.getPlayer(card.getOwnerId()); Player player = game.getPlayer(card.getOwnerId());
if (player != null) { if (player != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.HAND); player.moveCards(card, null, Zone.HAND, source, game);
int damage = card.getPower().getValue(); int damage = card.getPower().getValue();
Permanent creature = game.getPermanent(source.getTargets().get(1).getTargets().get(0)); Permanent creature = game.getPermanent(source.getTargets().get(1).getTargets().get(0));
if (creature != null) { if (creature != null) {

View file

@ -95,9 +95,9 @@ class FoulRenewalEffect extends OneShotEffect {
Card card = game.getCard(targetPointer.getFirst(game, source)); Card card = game.getCard(targetPointer.getFirst(game, source));
if (card != null) { if (card != null) {
int xValue = card.getToughness().getValue() * -1; int xValue = card.getToughness().getValue() * -1;
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD); controller.moveCards(card, null, Zone.HAND, source, game);
if (xValue != 0) { if (xValue != 0) {
ContinuousEffect effect = new BoostTargetEffect(xValue,xValue, Duration.EndOfTurn); ContinuousEffect effect = new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(source.getTargets().get(1).getFirstTarget())); effect.setTargetPointer(new FixedTarget(source.getTargets().get(1).getFirstTarget()));
game.addEffect(effect, source); game.addEffect(effect, source);
} }

View file

@ -60,7 +60,6 @@ import mage.game.stack.Spell;
import mage.players.Player; import mage.players.Player;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
/** /**
* *
* @author LevelX2 * @author LevelX2
@ -73,13 +72,13 @@ public class NarsetTranscendent extends CardImpl {
this.subtype.add("Narset"); this.subtype.add("Narset");
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(6)), false)); this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(6)), false));
// +1: Look at the top card of your library. If it's a noncreature, nonland card, you may reveal it and put it into your hand. // +1: Look at the top card of your library. If it's a noncreature, nonland card, you may reveal it and put it into your hand.
this.addAbility(new LoyaltyAbility(new NarsetTranscendentEffect1(), 1)); this.addAbility(new LoyaltyAbility(new NarsetTranscendentEffect1(), 1));
// -2: When you cast your next instant or sorcery spell from your hand this turn, it gains rebound. // -2: When you cast your next instant or sorcery spell from your hand this turn, it gains rebound.
this.addAbility(new LoyaltyAbility(new CreateDelayedTriggeredAbilityEffect(new NarsetTranscendentTriggeredAbility()), -2)); this.addAbility(new LoyaltyAbility(new CreateDelayedTriggeredAbilityEffect(new NarsetTranscendentTriggeredAbility()), -2));
// -9:You get an emblem with "Your opponents can't cast noncreature spells." // -9:You get an emblem with "Your opponents can't cast noncreature spells."
this.addAbility(new LoyaltyAbility(new GetEmblemEffect(new NarsetTranscendentEmblem()), -9)); this.addAbility(new LoyaltyAbility(new GetEmblemEffect(new NarsetTranscendentEmblem()), -9));
} }
@ -119,11 +118,11 @@ class NarsetTranscendentEffect1 extends OneShotEffect {
if (card != null) { if (card != null) {
CardsImpl cards = new CardsImpl(); CardsImpl cards = new CardsImpl();
cards.add(card); cards.add(card);
controller.lookAtCards(sourceObject.getName(), cards, game); controller.lookAtCards(sourceObject.getIdName(), cards, game);
if (!card.getCardType().contains(CardType.CREATURE) && !card.getCardType().contains(CardType.LAND)) { if (!card.getCardType().contains(CardType.CREATURE) && !card.getCardType().contains(CardType.LAND)) {
if (controller.chooseUse(outcome, "Reveal " + card.getName() + " and put it into your hand?", source, game)) { if (controller.chooseUse(outcome, "Reveal " + card.getLogName() + " and put it into your hand?", source, game)) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
} }
} }
return true; return true;
@ -142,6 +141,7 @@ class NarsetTranscendentTriggeredAbility extends DelayedTriggeredAbility {
private NarsetTranscendentTriggeredAbility(final NarsetTranscendentTriggeredAbility ability) { private NarsetTranscendentTriggeredAbility(final NarsetTranscendentTriggeredAbility ability) {
super(ability); super(ability);
} }
@Override @Override
public NarsetTranscendentTriggeredAbility copy() { public NarsetTranscendentTriggeredAbility copy() {
return new NarsetTranscendentTriggeredAbility(this); return new NarsetTranscendentTriggeredAbility(this);
@ -157,9 +157,9 @@ class NarsetTranscendentTriggeredAbility extends DelayedTriggeredAbility {
if (event.getPlayerId().equals(this.getControllerId())) { if (event.getPlayerId().equals(this.getControllerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId()); Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && spell.getFromZone().equals(Zone.HAND)) { if (spell != null && spell.getFromZone().equals(Zone.HAND)) {
if (spell.getCard() != null && if (spell.getCard() != null
spell.getCard().getCardType().contains(CardType.INSTANT) || spell.getCard().getCardType().contains(CardType.SORCERY)) { && spell.getCard().getCardType().contains(CardType.INSTANT) || spell.getCard().getCardType().contains(CardType.SORCERY)) {
for(Effect effect: getEffects()) { for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(spell.getId())); effect.setTargetPointer(new FixedTarget(spell.getId()));
} }
return true; return true;
@ -171,7 +171,7 @@ class NarsetTranscendentTriggeredAbility extends DelayedTriggeredAbility {
@Override @Override
public String getRule() { public String getRule() {
return "When you cast your next instant or sorcery spell from your hand this turn, " + super.getRule() ; return "When you cast your next instant or sorcery spell from your hand this turn, " + super.getRule();
} }
} }
@ -226,11 +226,11 @@ class NarsetTranscendentGainReboundEffect extends ContinuousEffectImpl {
class NarsetTranscendentEmblem extends Emblem { class NarsetTranscendentEmblem extends Emblem {
// "Your opponents can't cast noncreature spells. // "Your opponents can't cast noncreature spells.
public NarsetTranscendentEmblem() { public NarsetTranscendentEmblem() {
this.setName("EMBLEM: Narset Transcendent"); this.setName("EMBLEM: Narset Transcendent");
this.getAbilities().add(new SimpleStaticAbility(Zone.COMMAND, new NarsetTranscendentCantCastEffect())); this.getAbilities().add(new SimpleStaticAbility(Zone.COMMAND, new NarsetTranscendentCantCastEffect()));
} }
} }
@ -269,7 +269,7 @@ class NarsetTranscendentCantCastEffect extends ContinuousRuleModifyingEffectImpl
public boolean checksEventType(GameEvent event, Game game) { public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL; return event.getType() == GameEvent.EventType.CAST_SPELL;
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());

View file

@ -34,6 +34,8 @@ import mage.abilities.common.ExploitCreatureTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.ExploitAbility; import mage.abilities.keyword.ExploitAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.Cards;
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;
@ -99,9 +101,11 @@ class ProfanerOfTheDeadReturnEffect extends OneShotEffect {
FilterCreaturePermanent filter = new FilterCreaturePermanent(); FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerPredicate(TargetController.OPPONENT)); filter.add(new ControllerPredicate(TargetController.OPPONENT));
filter.add(new ToughnessPredicate(Filter.ComparisonType.LessThan, exploitedCreature.getToughness().getValue())); filter.add(new ToughnessPredicate(Filter.ComparisonType.LessThan, exploitedCreature.getToughness().getValue()));
Cards cardsToHand = new CardsImpl();
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD); cardsToHand.add(permanent);
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true; return true;
} }
return false; return false;

View file

@ -105,10 +105,10 @@ class VolcanicVisionReturnToHandTargetEffect extends OneShotEffect {
case GRAVEYARD: case GRAVEYARD:
Card card = game.getCard(targetId); Card card = game.getCard(targetId);
if (card != null) { if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD); controller.moveCards(card, null, Zone.HAND, source, game);
int damage = card.getManaCost().convertedManaCost(); int damage = card.getManaCost().convertedManaCost();
if (damage > 0) { if (damage > 0) {
for(Permanent creature: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
creature.damage(damage, source.getSourceId(), game, false, true); creature.damage(damage, source.getSourceId(), game, false, true);
} }
} }

View file

@ -32,12 +32,13 @@ 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.CardImpl; import mage.cards.CardImpl;
import mage.cards.Cards;
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.constants.Zone;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.NamePredicate; import mage.filter.predicate.mageobject.NamePredicate;
import mage.filter.predicate.permanent.PermanentIdPredicate; import mage.filter.predicate.permanent.PermanentIdPredicate;
import mage.game.Game; import mage.game.Game;
@ -96,11 +97,13 @@ class ReturnToHandAllNamedPermanentsEffect extends OneShotEffect {
if (permanent.getName().isEmpty()) { if (permanent.getName().isEmpty()) {
filter.add(new PermanentIdPredicate(permanent.getId())); // if no name (face down creature) only the creature itself is selected filter.add(new PermanentIdPredicate(permanent.getId())); // if no name (face down creature) only the creature itself is selected
} else { } else {
filter.add(new NamePredicate(permanent.getName())); filter.add(new NamePredicate(permanent.getName()));
} }
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { Cards cardsToHand = new CardsImpl();
controller.moveCardToHandWithInfo(perm, source.getSourceId(), game, Zone.BATTLEFIELD); for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
cardsToHand.add(perm);
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true; return true;
} }
return true; return true;

View file

@ -115,7 +115,7 @@ class RenownedWeaponsmithCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
MageObject object = game.getObject(source.getSourceId()); MageObject object = game.getObject(source.getSourceId());
return (object != null return (object != null
&& object.getCardType().contains(CardType.ARTIFACT)); && object.getCardType().contains(CardType.ARTIFACT));
} }
} }
@ -149,8 +149,8 @@ class RenownedWeaponsmithEffect extends OneShotEffect {
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
Cards revealed = new CardsImpl(); Cards revealed = new CardsImpl();
revealed.add(card); revealed.add(card);
controller.revealCards(sourceObject.getName(), revealed, game); controller.revealCards(sourceObject.getIdName(), revealed, game);
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(revealed, null, Zone.HAND, source, game);
} }
} }
controller.shuffleLibrary(game); controller.shuffleLibrary(game);

View file

@ -100,7 +100,7 @@ class SageEyeAvengersEffect extends OneShotEffect {
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null && targetCreature.getPower().getValue() < sourceObject.getPower().getValue()) { if (targetCreature != null && targetCreature.getPower().getValue() < sourceObject.getPower().getValue()) {
controller.moveCardToHandWithInfo(targetCreature, source.getSourceId(), game, Zone.BATTLEFIELD); controller.moveCards(targetCreature, null, Zone.HAND, source, game);
} }
return true; return true;
} }

View file

@ -130,28 +130,28 @@ class GainAbilitySpellsEffect extends ContinuousEffectImpl {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) { if (player != null && permanent != null) {
for (Card card: game.getExile().getAllCards(game)) { for (Card card : game.getExile().getAllCards(game)) {
if (card.getOwnerId().equals(source.getControllerId()) && filter.match(card, game)) { if (card.getOwnerId().equals(source.getControllerId()) && filter.match(card, game)) {
game.getState().addOtherAbility(card, ability); game.getState().addOtherAbility(card, ability);
} }
} }
for (Card card: player.getLibrary().getCards(game)) { for (Card card : player.getLibrary().getCards(game)) {
if (filter.match(card, game)) { if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability); game.getState().addOtherAbility(card, ability);
} }
} }
for (Card card: player.getHand().getCards(game)) { for (Card card : player.getHand().getCards(game)) {
if (filter.match(card, game)) { if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability); game.getState().addOtherAbility(card, ability);
} }
} }
for (Card card: player.getGraveyard().getCards(game)) { for (Card card : player.getGraveyard().getCards(game)) {
if (filter.match(card, game)) { if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability); game.getState().addOtherAbility(card, ability);
} }
} }
for (StackObject stackObject : game.getStack()) { for (StackObject stackObject : game.getStack()) {
if (stackObject.getControllerId().equals(source.getControllerId())) { if (stackObject.getControllerId().equals(source.getControllerId())) {
Card card = game.getCard(stackObject.getSourceId()); Card card = game.getCard(stackObject.getSourceId());
if (card != null && filter.match(card, game)) { if (card != null && filter.match(card, game)) {
if (!card.getAbilities().contains(ability)) { if (!card.getAbilities().contains(ability)) {
@ -199,15 +199,15 @@ class SoulfireGrandMasterCastFromHandReplacementEffect extends ReplacementEffect
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
MageObject mageObject = game.getObject(spellId); MageObject mageObject = game.getObject(spellId);
if (mageObject == null || !(mageObject instanceof Spell) || ((Spell)mageObject).isCopiedSpell()) { if (mageObject == null || !(mageObject instanceof Spell) || ((Spell) mageObject).isCopiedSpell()) {
return false; return false;
} else { } else {
Card sourceCard = game.getCard(spellId); Card sourceCard = game.getCard(spellId);
if (sourceCard != null) { if (sourceCard != null) {
Player player = game.getPlayer(sourceCard.getOwnerId()); Player player = game.getPlayer(sourceCard.getOwnerId());
if (player != null) { if (player != null) {
player.moveCardToHandWithInfo(sourceCard, source.getSourceId(), game, Zone.STACK); player.moveCards(sourceCard, null, Zone.HAND, source, game);
discard(); discard();
return true; return true;
} }
@ -215,6 +215,7 @@ class SoulfireGrandMasterCastFromHandReplacementEffect extends ReplacementEffect
} }
return false; return false;
} }
@Override @Override
public boolean checksEventType(GameEvent event, Game game) { public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE; return event.getType() == GameEvent.EventType.ZONE_CHANGE;
@ -225,21 +226,21 @@ class SoulfireGrandMasterCastFromHandReplacementEffect extends ReplacementEffect
//Something hit the stack from the hand, see if its a spell with this ability. //Something hit the stack from the hand, see if its a spell with this ability.
ZoneChangeEvent zEvent = (ZoneChangeEvent) event; ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (spellId == null && // because this effect works only once, spellId has to be null here if (spellId == null && // because this effect works only once, spellId has to be null here
zEvent.getFromZone() == Zone.HAND && zEvent.getFromZone() == Zone.HAND
zEvent.getToZone() == Zone.STACK && && zEvent.getToZone() == Zone.STACK
event.getPlayerId().equals(source.getControllerId())) { && event.getPlayerId().equals(source.getControllerId())) {
MageObject object = game.getObject(event.getTargetId()); MageObject object = game.getObject(event.getTargetId());
if (object instanceof Card) { if (object instanceof Card) {
if (filter.match((Card)object, game)) { if (filter.match((Card) object, game)) {
this.spellId = event.getTargetId(); this.spellId = event.getTargetId();
} }
} }
} else { } else {
// the spell goes to graveyard now so move it to hand again // the spell goes to graveyard now so move it to hand again
if (zEvent.getFromZone() == Zone.STACK && if (zEvent.getFromZone() == Zone.STACK
zEvent.getToZone() == Zone.GRAVEYARD && && zEvent.getToZone() == Zone.GRAVEYARD
event.getTargetId().equals(spellId)) { && event.getTargetId().equals(spellId)) {
Spell spell = game.getStack().getSpell(spellId); Spell spell = game.getStack().getSpell(spellId);
if (spell != null && !spell.isCountered()) { if (spell != null && !spell.isCountered()) {
return true; return true;
} }

View file

@ -33,6 +33,8 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PutTopCardOfLibraryIntoGraveControllerEffect; import mage.abilities.effects.common.PutTopCardOfLibraryIntoGraveControllerEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.Cards;
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;
@ -89,24 +91,26 @@ class SuddenReclamationEffect 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) {
Cards cardsToHand = new CardsImpl();
Target target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard")); Target target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard"));
target.setNotTarget(true); target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game) && if (target.canChoose(source.getSourceId(), controller.getId(), game)
controller.chooseTarget(outcome, target, source, game)) { && controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
if (card != null) { if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD); cardsToHand.add(card);
} }
} }
target = new TargetCardInYourGraveyard(new FilterLandCard("land card from your graveyard")); target = new TargetCardInYourGraveyard(new FilterLandCard("land card from your graveyard"));
target.setNotTarget(true); target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game) && if (target.canChoose(source.getSourceId(), controller.getId(), game)
controller.chooseTarget(outcome, target, source, game)) { && controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
if (card != null) { if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD); cardsToHand.add(card);
} }
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true; return true;
} }
return false; return false;

View file

@ -120,7 +120,7 @@ class TasigurTheGoldenFangEffect extends OneShotEffect {
opponent.chooseTarget(outcome, target, source, game); opponent.chooseTarget(outcome, target, source, game);
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
if (card != null) { if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD); controller.moveCards(card, null, Zone.HAND, source, game);
} }
} }
} }

View file

@ -103,13 +103,13 @@ class TemurSabertoothEffect 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) {
Target target = new TargetPermanent(1,1, filter, true); Target target = new TargetPermanent(1, 1, filter, true);
if (target.canChoose(source.getSourceId(), controller.getId(), game)) { if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
if (controller.chooseUse(outcome, "Return another creature to hand?", source, game) && if (controller.chooseUse(outcome, "Return another creature to hand?", source, game)
controller.chooseTarget(outcome, target, source, game)) { && controller.chooseTarget(outcome, target, source, game)) {
Permanent toHand = game.getPermanent(target.getFirstTarget()); Permanent toHand = game.getPermanent(target.getFirstTarget());
if (toHand != null) { if (toHand != null) {
controller.moveCardToHandWithInfo(toHand, source.getSourceId(), game, Zone.BATTLEFIELD); controller.moveCards(toHand, null, Zone.HAND, source, game);
} }
game.addEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn), source); game.addEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn), source);
} }

View file

@ -31,8 +31,9 @@ import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.ExileSpellEffect;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.Cards;
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;
@ -52,7 +53,6 @@ public class Recall extends CardImpl {
super(ownerId, 93, "Recall", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{X}{U}"); super(ownerId, 93, "Recall", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{X}{U}");
this.expansionSetCode = "5ED"; this.expansionSetCode = "5ED";
// Discard X cards, then return a card from your graveyard to your hand for each card discarded this way. // Discard X cards, then return a card from your graveyard to your hand for each card discarded this way.
this.getSpellAbility().addEffect(new RecallEffect()); this.getSpellAbility().addEffect(new RecallEffect());
// Exile Recall. // Exile Recall.
@ -75,38 +75,33 @@ class RecallEffect extends OneShotEffect {
super(Outcome.ReturnToHand); super(Outcome.ReturnToHand);
this.staticText = "Discard X cards, then return a card from your graveyard to your hand for each card discarded this way. "; this.staticText = "Discard X cards, then return a card from your graveyard to your hand for each card discarded this way. ";
} }
public RecallEffect(final RecallEffect effect) { public RecallEffect(final RecallEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public RecallEffect copy() { public RecallEffect copy() {
return new RecallEffect(this); return new RecallEffect(this);
} }
@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) {
// Discard X cards // Discard X cards
int amount = source.getManaCostsToPay().getX(); Cards cardsDiscarded = controller.discard(source.getManaCostsToPay().getX(), false, source, game);
int discarded = Math.min(amount, player.getHand().size()); if (!cardsDiscarded.isEmpty()) {
player.discard(amount, false, source, game); // then return a card from your graveyard to your hand for each card discarded this way
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(cardsDiscarded.size(), new FilterCard());
// then return a card from your graveyard to your hand for each card discarded this way target.setNotTarget(true);
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(discarded, new FilterCard()); target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), game);
target.choose(Outcome.ReturnToHand, player.getId(), source.getSourceId(), game); controller.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game);
for (UUID targetId : target.getTargets()) {
Card card = game.getCard(targetId);
if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
}
} }
return true; return true;
} }
return false; return false;
} }
} }

View file

@ -76,13 +76,13 @@ public class LinessaZephyrMage extends CardImpl {
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent()); ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability); this.addAbility(ability);
// Grandeur - Discard another card named Linessa, Zephyr Mage: Target player returns a creature he or she controls to its owner's hand, then repeats this process for an artifact, an enchantment, and a land. // Grandeur - Discard another card named Linessa, Zephyr Mage: Target player returns a creature he or she controls to its owner's hand, then repeats this process for an artifact, an enchantment, and a land.
ability = new GrandeurAbility(new LinessaZephyrMageEffect(), "Linessa, Zephyr Mage"); ability = new GrandeurAbility(new LinessaZephyrMageEffect(), "Linessa, Zephyr Mage");
ability.addTarget(new TargetPlayer()); ability.addTarget(new TargetPlayer());
this.addAbility(ability); this.addAbility(ability);
} }
public LinessaZephyrMage(final LinessaZephyrMage card) { public LinessaZephyrMage(final LinessaZephyrMage card) {
super(card); super(card);
} }
@ -105,21 +105,21 @@ public class LinessaZephyrMage extends CardImpl {
} }
class LinessaZephyrMageEffect extends OneShotEffect { class LinessaZephyrMageEffect extends OneShotEffect {
LinessaZephyrMageEffect() { LinessaZephyrMageEffect() {
super(Outcome.ReturnToHand); super(Outcome.ReturnToHand);
this.staticText = "Target player returns a creature he or she controls to its owner's hand, then repeats this process for an artifact, an enchantment, and a land"; this.staticText = "Target player returns a creature he or she controls to its owner's hand, then repeats this process for an artifact, an enchantment, and a land";
} }
LinessaZephyrMageEffect(final LinessaZephyrMageEffect effect) { LinessaZephyrMageEffect(final LinessaZephyrMageEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public LinessaZephyrMageEffect copy() { public LinessaZephyrMageEffect copy() {
return new LinessaZephyrMageEffect(this); return new LinessaZephyrMageEffect(this);
} }
@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());
@ -132,7 +132,7 @@ class LinessaZephyrMageEffect extends OneShotEffect {
if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) { if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget()); Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) { if (permanent != null) {
targetPlayer.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD); targetPlayer.moveCards(permanent, null, Zone.HAND, source, game);
} }
} }
@ -144,10 +144,10 @@ class LinessaZephyrMageEffect extends OneShotEffect {
if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) { if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget()); Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) { if (permanent != null) {
targetPlayer.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD); targetPlayer.moveCards(permanent, null, Zone.HAND, source, game);
} }
} }
// an enchantment, // an enchantment,
filter = new FilterControlledPermanent("enchantment you control"); filter = new FilterControlledPermanent("enchantment you control");
filter.add(new CardTypePredicate(CardType.ENCHANTMENT)); filter.add(new CardTypePredicate(CardType.ENCHANTMENT));
@ -156,10 +156,10 @@ class LinessaZephyrMageEffect extends OneShotEffect {
if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) { if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget()); Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) { if (permanent != null) {
targetPlayer.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD); targetPlayer.moveCards(permanent, null, Zone.HAND, source, game);
} }
} }
// and a land. // and a land.
filter = new FilterControlledPermanent("land you control"); filter = new FilterControlledPermanent("land you control");
filter.add(new CardTypePredicate(CardType.LAND)); filter.add(new CardTypePredicate(CardType.LAND));
@ -168,10 +168,10 @@ class LinessaZephyrMageEffect extends OneShotEffect {
if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) { if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget()); Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) { if (permanent != null) {
targetPlayer.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD); targetPlayer.moveCards(permanent, null, Zone.HAND, source, game);
} }
} }
return true; return true;
} }
} }

View file

@ -103,18 +103,19 @@ class VenserShaperSavantEffect extends OneShotEffect {
if (controller != null) { if (controller != null) {
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source)); Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (permanent != null) { if (permanent != null) {
return controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD); return controller.moveCards(permanent, null, Zone.HAND, source, game);
} }
/** /**
* 01.05.2007 If a spell is returned to its owner's hand, it's removed from * 01.05.2007 If a spell is returned to its owner's hand, it's
* the stack and thus will not resolve. The spell isn't countered; it just no longer exists. * removed from the stack and thus will not resolve. The spell isn't
* 01.05.2007 If a copy of a spell is returned to its owner's hand, it's moved there, * countered; it just no longer exists. 01.05.2007 If a copy of a
* then it will cease to exist as a state-based action. * spell is returned to its owner's hand, it's moved there, then it
* 01.05.2007 If Venser's enters-the-battlefield ability targets a spell cast with flashback, * will cease to exist as a state-based action. 01.05.2007 If
* that spell will be exiled instead of returning to its owner's hand. * Venser's enters-the-battlefield ability targets a spell cast with
* flashback, that spell will be exiled instead of returning to its
* owner's hand.
*/ */
Spell spell = game.getStack().getSpell(this.getTargetPointer().getFirst(game, source)); Spell spell = game.getStack().getSpell(this.getTargetPointer().getFirst(game, source));
if (spell != null) { if (spell != null) {
Card card = null; Card card = null;
@ -123,7 +124,7 @@ class VenserShaperSavantEffect extends OneShotEffect {
} }
game.getStack().remove(spell); game.getStack().remove(spell);
if (card != null) { if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.STACK); controller.moveCards(card, null, Zone.HAND, source, game);
} }
return true; return true;
} }

View file

@ -28,15 +28,15 @@
package mage.sets.gatecrash; package mage.sets.gatecrash;
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.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
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.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -95,8 +95,8 @@ class DinrovaHorrorEffect extends OneShotEffect {
if (target != null) { if (target != null) {
Player controller = game.getPlayer(target.getControllerId()); Player controller = game.getPlayer(target.getControllerId());
if (controller != null) { if (controller != null) {
controller.moveCardToHandWithInfo(target, source.getSourceId(), game, Zone.BATTLEFIELD); controller.moveCards(target, null, Zone.HAND, source, game);
controller.discard(1, source, game); controller.discard(1, false, source, game);
return true; return true;
} }
} }

View file

@ -29,11 +29,6 @@ package mage.sets.gatecrash;
import java.util.UUID; import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldAbility;
@ -50,7 +45,11 @@ import mage.abilities.keyword.TrampleAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
@ -71,8 +70,6 @@ public class DomriRade extends CardImpl {
this.expansionSetCode = "GTC"; this.expansionSetCode = "GTC";
this.subtype.add("Domri"); this.subtype.add("Domri");
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(3)), false)); this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(3)), false));
// +1: Look at the top card of your library. If it's a creature card, you may reveal it and put it into your hand. // +1: Look at the top card of your library. If it's a creature card, you may reveal it and put it into your hand.
@ -127,8 +124,8 @@ class DomriRadeEffect1 extends OneShotEffect {
controller.lookAtCards(sourceObject.getName(), cards, game); controller.lookAtCards(sourceObject.getName(), cards, game);
if (card.getCardType().contains(CardType.CREATURE)) { if (card.getCardType().contains(CardType.CREATURE)) {
if (controller.chooseUse(outcome, "Reveal " + card.getName() + " and put it into your hand?", source, game)) { if (controller.chooseUse(outcome, "Reveal " + card.getName() + " and put it into your hand?", source, game)) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
} }
} }
return true; return true;
@ -139,7 +136,9 @@ class DomriRadeEffect1 extends OneShotEffect {
} }
class DomriRadeEmblem extends Emblem { class DomriRadeEmblem extends Emblem {
// "Creatures you control have double strike, trample, hexproof and haste." // "Creatures you control have double strike, trample, hexproof and haste."
public DomriRadeEmblem() { public DomriRadeEmblem() {
this.setName("EMBLEM: Domri Rade"); this.setName("EMBLEM: Domri Rade");
FilterPermanent filter = new FilterControlledCreaturePermanent("Creatures"); FilterPermanent filter = new FilterControlledCreaturePermanent("Creatures");
@ -156,7 +155,7 @@ class DomriRadeEmblem extends Emblem {
} }
class DomriRadeTargetOtherCreaturePermanent extends TargetCreaturePermanent { class DomriRadeTargetOtherCreaturePermanent extends TargetCreaturePermanent {
public DomriRadeTargetOtherCreaturePermanent() { public DomriRadeTargetOtherCreaturePermanent() {
super(); super();
} }

View file

@ -28,6 +28,7 @@
package mage.sets.iceage; package mage.sets.iceage;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
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;
@ -54,7 +55,6 @@ public class DemonicConsultation extends CardImpl {
super(ownerId, 9, "Demonic Consultation", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{B}"); super(ownerId, 9, "Demonic Consultation", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{B}");
this.expansionSetCode = "ICE"; this.expansionSetCode = "ICE";
// Name a card. Exile the top six cards of your library, then reveal cards from the top of your library until you reveal the named card. Put that card into your hand and exile all other cards revealed this way. // Name a card. Exile the top six cards of your library, then reveal cards from the top of your library until you reveal the named card. Put that card into your hand and exile all other cards revealed this way.
this.getSpellAbility().addEffect(new DemonicConsultationEffect()); this.getSpellAbility().addEffect(new DemonicConsultationEffect());
} }
@ -70,63 +70,58 @@ public class DemonicConsultation extends CardImpl {
} }
class DemonicConsultationEffect extends OneShotEffect { class DemonicConsultationEffect extends OneShotEffect {
DemonicConsultationEffect() { DemonicConsultationEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
this.staticText = "Name a card. Exile the top six cards of your library, then reveal cards from the top of your library until you reveal the named card. Put that card into your hand and exile all other cards revealed this way"; this.staticText = "Name a card. Exile the top six cards of your library, then reveal cards from the top of your library until you reveal the named card. Put that card into your hand and exile all other cards revealed this way";
} }
DemonicConsultationEffect(final DemonicConsultationEffect effect) { DemonicConsultationEffect(final DemonicConsultationEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public DemonicConsultationEffect copy() { public DemonicConsultationEffect copy() {
return new DemonicConsultationEffect(this); return new DemonicConsultationEffect(this);
} }
@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) { MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
// Name a card. // Name a card.
Choice choice = new ChoiceImpl(); Choice choice = new ChoiceImpl();
choice.setChoices(CardRepository.instance.getNames()); choice.setChoices(CardRepository.instance.getNames());
while (!player.choose(Outcome.Benefit, choice, game)) { while (!controller.choose(Outcome.Benefit, choice, game)) {
if (!player.canRespond()) { if (!controller.canRespond()) {
return false; return false;
} }
} }
String name = choice.getChoice(); String name = choice.getChoice();
game.informPlayers("Card named: " + name); game.informPlayers("Card named: " + name);
// Exile the top six cards of your library, // Exile the top six cards of your library,
int num = Math.min(6, player.getLibrary().size()); controller.moveCards(controller.getLibrary().getTopCards(game, 6), null, Zone.EXILED, source, game);
for (int i = 0; i < num; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
player.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
}
}
// then reveal cards from the top of your library until you reveal the named card. // then reveal cards from the top of your library until you reveal the named card.
Cards cards = new CardsImpl(Zone.LIBRARY); Cards cardsToReaveal = new CardsImpl();
while (player.getLibrary().size() > 0) { Card cardToHand = null;
Card card = player.getLibrary().removeFromTop(game); while (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) { if (card != null) {
cards.add(card); cardsToReaveal.add(card);
// Put that card into your hand // Put that card into your hand
if (card.getName().equals(name)) { if (card.getName().equals(name)) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); cardToHand = card;
break; break;
} }
// and exile all other cards revealed this way.
else {
player.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
}
} }
} }
player.revealCards("Demonic Consultation", cards, game); controller.moveCards(cardToHand, null, Zone.HAND, source, game);
controller.revealCards(sourceObject.getIdName(), cardsToReaveal, game);
cardsToReaveal.remove(cardToHand);
controller.moveCards(cardsToReaveal, null, Zone.EXILED, source, game);
return true; return true;
} }
return false; return false;

View file

@ -29,10 +29,6 @@ package mage.sets.innistrad;
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.condition.common.MorbidCondition; import mage.abilities.condition.common.MorbidCondition;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -40,6 +36,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.filter.common.FilterBasicLandCard; import mage.filter.common.FilterBasicLandCard;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
@ -55,7 +55,6 @@ public class CaravanVigil extends CardImpl {
super(ownerId, 173, "Caravan Vigil", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{G}"); super(ownerId, 173, "Caravan Vigil", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{G}");
this.expansionSetCode = "ISD"; this.expansionSetCode = "ISD";
// Search your library for a basic land card, reveal it, put it into your hand, then shuffle your library. // Search your library for a basic land card, reveal it, put it into your hand, then shuffle your library.
// Morbid - You may put that card onto the battlefield instead of putting it into your hand if a creature died this turn. // Morbid - You may put that card onto the battlefield instead of putting it into your hand if a creature died this turn.
this.getSpellAbility().addEffect(new CaravanVigilEffect()); this.getSpellAbility().addEffect(new CaravanVigilEffect());
@ -103,10 +102,10 @@ class CaravanVigilEffect extends OneShotEffect {
&& controller.chooseUse(Outcome.PutLandInPlay, "Do you wish to put the card onto the battlefield instead?", source, game)) { && controller.chooseUse(Outcome.PutLandInPlay, "Do you wish to put the card onto the battlefield instead?", source, game)) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
} else { } else {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
} }
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
} }
} }
controller.shuffleLibrary(game); controller.shuffleLibrary(game);
return true; return true;

View file

@ -50,11 +50,10 @@ public class Recoil extends CardImpl {
super(ownerId, 264, "Recoil", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{U}{B}"); super(ownerId, 264, "Recoil", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{U}{B}");
this.expansionSetCode = "INV"; this.expansionSetCode = "INV";
// Return target permanent to its owner's hand. Then that player discards a card. // Return target permanent to its owner's hand. Then that player discards a card.
this.getSpellAbility().addEffect(new RecoilEffect()); this.getSpellAbility().addEffect(new RecoilEffect());
this.getSpellAbility().addTarget(new TargetPermanent()); this.getSpellAbility().addTarget(new TargetPermanent());
} }
public Recoil(final Recoil card) { public Recoil(final Recoil card) {
@ -86,13 +85,11 @@ class RecoilEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent target = game.getPermanent(source.getFirstTarget()); Permanent target = game.getPermanent(source.getFirstTarget());
if (target != null) { Player controller = game.getPlayer(target.getControllerId());
Player controller = game.getPlayer(target.getControllerId()); if (target != null && controller != null) {
if (controller != null) { controller.moveCards(target, null, Zone.HAND, source, game);
controller.moveCardToHandWithInfo(target, source.getSourceId(), game, Zone.BATTLEFIELD); controller.discard(1, false, source, game);
controller.discard(1, source, game); return true;
return true;
}
} }
return false; return false;
} }

View file

@ -64,12 +64,12 @@ import mage.target.common.TargetOpponent;
public class AthreosGodOfPassage extends CardImpl { public class AthreosGodOfPassage extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature you own"); private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature you own");
static { static {
filter.add(new AnotherPredicate()); filter.add(new AnotherPredicate());
filter.add(new OwnerPredicate(TargetController.YOU)); filter.add(new OwnerPredicate(TargetController.YOU));
} }
public AthreosGodOfPassage(UUID ownerId) { public AthreosGodOfPassage(UUID ownerId) {
super(ownerId, 146, "Athreos, God of Passage", Rarity.MYTHIC, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{1}{W}{B}"); super(ownerId, 146, "Athreos, God of Passage", Rarity.MYTHIC, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{1}{W}{B}");
this.expansionSetCode = "JOU"; this.expansionSetCode = "JOU";
@ -84,12 +84,12 @@ public class AthreosGodOfPassage extends CardImpl {
// As long as your devotion to white and black is less than seven, Athreos isn't a creature. // As long as your devotion to white and black is less than seven, Athreos isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(new DevotionCount(ColoredManaSymbol.W, ColoredManaSymbol.B), 7); Effect effect = new LoseCreatureTypeSourceEffect(new DevotionCount(ColoredManaSymbol.W, ColoredManaSymbol.B), 7);
effect.setText("As long as your devotion to white and black is less than seven, Athreos isn't a creature"); effect.setText("As long as your devotion to white and black is less than seven, Athreos isn't a creature");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
// Whenever another creature you own dies, return it to your hand unless target opponent pays 3 life. // Whenever another creature you own dies, return it to your hand unless target opponent pays 3 life.
Ability ability = new AthreosDiesCreatureTriggeredAbility(new AthreosGodOfPassageReturnEffect(), false, filter); Ability ability = new AthreosDiesCreatureTriggeredAbility(new AthreosGodOfPassageReturnEffect(), false, filter);
ability.addTarget(new TargetOpponent()); ability.addTarget(new TargetOpponent());
this.addAbility(ability); this.addAbility(ability);
} }
public AthreosGodOfPassage(final AthreosGodOfPassage card) { public AthreosGodOfPassage(final AthreosGodOfPassage card) {
@ -103,21 +103,21 @@ public class AthreosGodOfPassage extends CardImpl {
} }
class AthreosGodOfPassageReturnEffect extends OneShotEffect { class AthreosGodOfPassageReturnEffect extends OneShotEffect {
public AthreosGodOfPassageReturnEffect() { public AthreosGodOfPassageReturnEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
this.staticText = "return it to your hand unless target opponent pays 3 life"; this.staticText = "return it to your hand unless target opponent pays 3 life";
} }
public AthreosGodOfPassageReturnEffect(final AthreosGodOfPassageReturnEffect effect) { public AthreosGodOfPassageReturnEffect(final AthreosGodOfPassageReturnEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public AthreosGodOfPassageReturnEffect copy() { public AthreosGodOfPassageReturnEffect copy() {
return new AthreosGodOfPassageReturnEffect(this); return new AthreosGodOfPassageReturnEffect(this);
} }
@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());
@ -134,13 +134,13 @@ class AthreosGodOfPassageReturnEffect extends OneShotEffect {
if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false)) { if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false)) {
paid = true; paid = true;
} }
} }
} }
if (opponent == null || !paid) { if (opponent == null || !paid) {
if (game.getState().getZone(creature.getId()).equals(Zone.GRAVEYARD)) { if (game.getState().getZone(creature.getId()).equals(Zone.GRAVEYARD)) {
controller.moveCardToHandWithInfo(creature, source.getSourceId(), game, Zone.GRAVEYARD); controller.moveCards(creature, null, Zone.HAND, source, game);
} }
} }
} }
return true; return true;
} }

View file

@ -27,7 +27,6 @@
*/ */
package mage.sets.journeyintonyx; package mage.sets.journeyintonyx;
import java.util.LinkedList;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
@ -74,7 +73,7 @@ public class BrainMaggot extends CardImpl {
Ability ability = new EntersBattlefieldTriggeredAbility(new BrainMaggotExileEffect()); Ability ability = new EntersBattlefieldTriggeredAbility(new BrainMaggotExileEffect());
ability.addTarget(new TargetOpponent()); ability.addTarget(new TargetOpponent());
ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new BrainMaggotReturnExiledCardAbility())); ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new BrainMaggotReturnExiledCardAbility()));
this.addAbility(ability); this.addAbility(ability);
} }
public BrainMaggot(final BrainMaggot card) { public BrainMaggot(final BrainMaggot card) {
@ -110,7 +109,7 @@ class BrainMaggotExileEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && opponent != null && sourcePermanent != null) { if (controller != null && opponent != null && sourcePermanent != null) {
if (!opponent.getHand().isEmpty()) { if (!opponent.getHand().isEmpty()) {
opponent.revealCards(sourcePermanent.getName(), opponent.getHand(), game); opponent.revealCards(sourcePermanent.getIdName(), opponent.getHand(), game);
FilterCard filter = new FilterNonlandCard("nonland card to exile"); FilterCard filter = new FilterNonlandCard("nonland card to exile");
TargetCard target = new TargetCard(Zone.HAND, filter); TargetCard target = new TargetCard(Zone.HAND, filter);
@ -130,11 +129,10 @@ class BrainMaggotExileEffect extends OneShotEffect {
} }
/** /**
* Returns the exiled card as source permanent leaves battlefield * Returns the exiled card as source permanent leaves battlefield Uses no stack
* Uses no stack *
* @author LevelX2 * @author LevelX2
*/ */
class BrainMaggotReturnExiledCardAbility extends DelayedTriggeredAbility { class BrainMaggotReturnExiledCardAbility extends DelayedTriggeredAbility {
public BrainMaggotReturnExiledCardAbility() { public BrainMaggotReturnExiledCardAbility() {
@ -190,18 +188,13 @@ class BrainMaggotReturnExiledCardEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() -1; int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1;
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter)); ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (exile != null && sourcePermanent != null) { if (exile != null && sourcePermanent != null) {
LinkedList<UUID> cards = new LinkedList<>(exile); controller.moveCards(exile, null, Zone.HAND, source, game);
for (UUID cardId : cards) {
Card card = game.getCard(cardId);
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.EXILED);
}
exile.clear();
return true; return true;
} }
} }
return false; return false;
} }

View file

@ -31,6 +31,8 @@ import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.Cards;
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;
@ -52,12 +54,10 @@ public class Hubris extends CardImpl {
super(ownerId, 41, "Hubris", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{U}"); super(ownerId, 41, "Hubris", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{U}");
this.expansionSetCode = "JOU"; this.expansionSetCode = "JOU";
// Return target creature and all Auras attached to it to their owners' hand. // Return target creature and all Auras attached to it to their owners' hand.
this.getSpellAbility().addEffect(new HubrisReturnEffect()); this.getSpellAbility().addEffect(new HubrisReturnEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent());
} }
public Hubris(final Hubris card) { public Hubris(final Hubris card) {
@ -96,16 +96,12 @@ class HubrisReturnEffect 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 (UUID targetId: targetPointer.getTargets(game, source)) { for (UUID targetId : targetPointer.getTargets(game, source)) {
Permanent creature = game.getPermanent(targetId); Permanent creature = game.getPermanent(targetId);
if (creature != null) { if (creature != null) {
controller.moveCardToHandWithInfo(creature, source.getSourceId(), game, Zone.BATTLEFIELD); Cards cardsToHand = new CardsImpl(creature.getAttachments());
for (UUID attachementId: creature.getAttachments()) { cardsToHand.add(creature);
Permanent attachment = game.getPermanent(attachementId); controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
if (attachment != null && filter.match(attachment, game)) {
controller.moveCardToHandWithInfo(attachment, source.getSourceId(), game, Zone.BATTLEFIELD);
}
}
} }
} }
return true; return true;

View file

@ -101,36 +101,30 @@ class NessianGameWardenEffect 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 sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player == null || sourcePermanent == null) { if (controller == null || sourcePermanent == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
int count = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this); int count = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
count = Math.min(player.getLibrary().size(), count); cards.addAll(controller.getLibrary().getTopCards(game, count));
for (int i = 0; i < count; i++) { controller.lookAtCards(sourcePermanent.getIdName(), cards, game);
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
player.lookAtCards(sourcePermanent.getName(), cards, game);
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to put into your hand")); TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to put into your hand"));
if (target.canChoose(source.getSourceId(), player.getId(), game) && player.choose(Outcome.DrawCard, cards, target, game)) { if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game); Card card = cards.get(target.getFirstTarget(), game);
if (card != null) { if (card != null) {
player.revealCards(sourcePermanent.getName(), new CardsImpl(card), game); controller.revealCards(sourcePermanent.getName(), new CardsImpl(card), game);
cards.remove(card); cards.remove(card);
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
} }
} }
} }
player.putCardsOnBottomOfLibrary(cards, game, source, true); controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true; return true;
} }
} }

View file

@ -33,6 +33,8 @@ import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.Cards;
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;
@ -78,27 +80,27 @@ public class ScourgeOfFleets extends CardImpl {
} }
class ScourgeOfFleetsEffect extends OneShotEffect { class ScourgeOfFleetsEffect extends OneShotEffect {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("number of Islands you control"); private static final FilterControlledPermanent filter = new FilterControlledPermanent("number of Islands you control");
static { static {
filter.add(new SubtypePredicate("Island")); filter.add(new SubtypePredicate("Island"));
} }
public ScourgeOfFleetsEffect() { public ScourgeOfFleetsEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
this.staticText = "return each creature your opponents control with toughness X or less, where X is the number of Islands you control"; this.staticText = "return each creature your opponents control with toughness X or less, where X is the number of Islands you control";
} }
public ScourgeOfFleetsEffect(final ScourgeOfFleetsEffect effect) { public ScourgeOfFleetsEffect(final ScourgeOfFleetsEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public ScourgeOfFleetsEffect copy() { public ScourgeOfFleetsEffect copy() {
return new ScourgeOfFleetsEffect(this); return new ScourgeOfFleetsEffect(this);
} }
@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());
@ -106,10 +108,12 @@ class ScourgeOfFleetsEffect extends OneShotEffect {
int islands = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); int islands = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
FilterPermanent creatureFilter = new FilterCreaturePermanent(); FilterPermanent creatureFilter = new FilterCreaturePermanent();
creatureFilter.add(new ControllerPredicate(TargetController.OPPONENT)); creatureFilter.add(new ControllerPredicate(TargetController.OPPONENT));
creatureFilter.add(new ToughnessPredicate(Filter.ComparisonType.LessThan, islands +1)); creatureFilter.add(new ToughnessPredicate(Filter.ComparisonType.LessThan, islands + 1));
for (Permanent permanent: game.getBattlefield().getActivePermanents(creatureFilter, source.getControllerId(), source.getSourceId(), game)) { Cards cardsToHand = new CardsImpl();
controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD); for (Permanent permanent : game.getBattlefield().getActivePermanents(creatureFilter, source.getControllerId(), source.getSourceId(), game)) {
cardsToHand.add(permanent);
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true; return true;
} }
return false; return false;

View file

@ -1,16 +1,16 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,16 +20,15 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * The views and conclusions contained in the software and documentation are those of the
* 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.magic2011; package mage.sets.magic2011;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
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;
@ -93,41 +92,44 @@ class CultivateEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterBasicLandCard()); TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterBasicLandCard());
Player player = game.getPlayer(source.getControllerId()); if (controller.searchLibrary(target, game)) {
if (player.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) { if (target.getTargets().size() > 0) {
Cards revealed = new CardsImpl(); Cards revealed = new CardsImpl();
for (UUID cardId: (List<UUID>)target.getTargets()) { for (UUID cardId : target.getTargets()) {
Card card = player.getLibrary().getCard(cardId, game); Card card = controller.getLibrary().getCard(cardId, game);
revealed.add(card); revealed.add(card);
} }
player.revealCards("Cultivate", revealed, game); controller.revealCards(sourceObject.getIdName(), revealed, game);
if (target.getTargets().size() == 2) { if (target.getTargets().size() == 2) {
TargetCard target2 = new TargetCard(Zone.LIBRARY, filter); TargetCard target2 = new TargetCard(Zone.LIBRARY, filter);
player.choose(Outcome.Benefit, revealed, target2, game); controller.choose(Outcome.Benefit, revealed, target2, game);
Card card = revealed.get(target2.getFirstTarget(), game); Card card = revealed.get(target2.getFirstTarget(), game);
if (card != null) { if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
revealed.remove(card); revealed.remove(card);
} }
card = revealed.getCards(game).iterator().next(); card = revealed.getCards(game).iterator().next();
if (card != null) { if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
} }
} } else if (target.getTargets().size() == 1) {
else if (target.getTargets().size() == 1) {
Card card = revealed.getCards(game).iterator().next(); Card card = revealed.getCards(game).iterator().next();
if (card != null) { if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
} }
} }
} }
player.shuffleLibrary(game); controller.shuffleLibrary(game);
return true; return true;
} }
player.shuffleLibrary(game); controller.shuffleLibrary(game);
return false; return false;
} }

View file

@ -79,6 +79,7 @@ public class Quickling extends CardImpl {
return new Quickling(this); return new Quickling(this);
} }
} }
class QuicklingEffect extends OneShotEffect { class QuicklingEffect extends OneShotEffect {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("another creature you control"); private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("another creature you control");
@ -88,12 +89,12 @@ class QuicklingEffect extends OneShotEffect {
filter.add(new AnotherPredicate()); filter.add(new AnotherPredicate());
} }
QuicklingEffect ( ) { QuicklingEffect() {
super(Outcome.ReturnToHand); super(Outcome.ReturnToHand);
staticText = effectText; staticText = effectText;
} }
QuicklingEffect ( QuicklingEffect effect ) { QuicklingEffect(QuicklingEffect effect) {
super(effect); super(effect);
} }
@ -106,13 +107,13 @@ class QuicklingEffect extends OneShotEffect {
if (target.canChoose(controller.getId(), game) && controller.chooseUse(outcome, "Return another creature you control to its owner's hand?", source, game)) { if (target.canChoose(controller.getId(), game) && controller.chooseUse(outcome, "Return another creature you control to its owner's hand?", source, game)) {
controller.chooseTarget(Outcome.ReturnToHand, target, source, game); controller.chooseTarget(Outcome.ReturnToHand, target, source, game);
Permanent permanent = game.getPermanent(target.getFirstTarget()); Permanent permanent = game.getPermanent(target.getFirstTarget());
if ( permanent != null ) { if (permanent != null) {
targetChosen = true; targetChosen = true;
controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD); controller.moveCards(permanent, null, Zone.HAND, source, game);
} }
} }
if ( !targetChosen ) { if (!targetChosen) {
new SacrificeSourceEffect().apply(game, source); new SacrificeSourceEffect().apply(game, source);
} }
return true; return true;

View file

@ -57,7 +57,6 @@ public class ForbiddenCrypt extends CardImpl {
super(ownerId, 22, "Forbidden Crypt", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{B}{B}"); super(ownerId, 22, "Forbidden Crypt", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{B}{B}");
this.expansionSetCode = "MIR"; this.expansionSetCode = "MIR";
// If you would draw a card, return a card from your graveyard to your hand instead. If you can't, you lose the game. // If you would draw a card, return a card from your graveyard to your hand instead. If you can't, you lose the game.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ForbiddenCryptDrawCardReplacementEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ForbiddenCryptDrawCardReplacementEffect()));
// If a card would be put into your graveyard from anywhere, exile that card instead. // If a card would be put into your graveyard from anywhere, exile that card instead.
@ -80,7 +79,7 @@ class ForbiddenCryptDrawCardReplacementEffect extends ReplacementEffectImpl {
super(Duration.WhileOnBattlefield, Outcome.Neutral); super(Duration.WhileOnBattlefield, Outcome.Neutral);
this.staticText = "If you would draw a card, return a card from your graveyard to your hand instead. If you can't, you lose the game"; this.staticText = "If you would draw a card, return a card from your graveyard to your hand instead. If you can't, you lose the game";
} }
public ForbiddenCryptDrawCardReplacementEffect(final ForbiddenCryptDrawCardReplacementEffect effect) { public ForbiddenCryptDrawCardReplacementEffect(final ForbiddenCryptDrawCardReplacementEffect effect) {
super(effect); super(effect);
} }
@ -92,22 +91,23 @@ class ForbiddenCryptDrawCardReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (player != null) { if (controller != null) {
boolean cardReturned = false; boolean cardReturned = false;
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(); TargetCardInYourGraveyard target = new TargetCardInYourGraveyard();
if (target.canChoose(source.getSourceId(), player.getId(), game)) { target.setNotTarget(true);
if (target.choose(Outcome.ReturnToHand, player.getId(), source.getSourceId(), game)) { if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
if (target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
if (card != null) { if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD); controller.moveCards(card, null, Zone.HAND, source, game);
cardReturned = true; cardReturned = true;
} }
} }
} }
if (!cardReturned) { if (!cardReturned) {
game.informPlayers(new StringBuilder(player.getLogName()).append(" can't return a card from graveyard to hand.").toString()); game.informPlayers(controller.getLogName() + " can't return a card from graveyard to hand.");
player.lost(game); controller.lost(game);
} }
return true; return true;
} }
@ -118,12 +118,12 @@ class ForbiddenCryptDrawCardReplacementEffect extends ReplacementEffectImpl {
public boolean checksEventType(GameEvent event, Game game) { public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.DRAW_CARD; return event.getType() == EventType.DRAW_CARD;
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
return event.getPlayerId().equals(source.getControllerId()); return event.getPlayerId().equals(source.getControllerId());
} }
} }
class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEffectImpl { class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEffectImpl {
@ -132,7 +132,7 @@ class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEff
super(Duration.WhileOnBattlefield, Outcome.Detriment); super(Duration.WhileOnBattlefield, Outcome.Detriment);
this.staticText = "If a card would be put into your graveyard from anywhere, exile that card instead"; this.staticText = "If a card would be put into your graveyard from anywhere, exile that card instead";
} }
public ForbiddenCryptPutIntoYourGraveyardReplacementEffect(final ForbiddenCryptPutIntoYourGraveyardReplacementEffect effect) { public ForbiddenCryptPutIntoYourGraveyardReplacementEffect(final ForbiddenCryptPutIntoYourGraveyardReplacementEffect effect) {
super(effect); super(effect);
} }
@ -141,7 +141,7 @@ class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEff
public ForbiddenCryptPutIntoYourGraveyardReplacementEffect copy() { public ForbiddenCryptPutIntoYourGraveyardReplacementEffect copy() {
return new ForbiddenCryptPutIntoYourGraveyardReplacementEffect(this); return new ForbiddenCryptPutIntoYourGraveyardReplacementEffect(this);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return true; return true;
@ -166,12 +166,12 @@ class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEff
} }
return true; return true;
} }
@Override @Override
public boolean checksEventType(GameEvent event, Game game) { public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.ZONE_CHANGE; return event.getType() == EventType.ZONE_CHANGE;
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) { if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) {
@ -185,5 +185,5 @@ class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEff
} }
return false; return false;
} }
} }

View file

@ -53,7 +53,6 @@ public class SpoilsOfTheVault extends CardImpl {
super(ownerId, 78, "Spoils of the Vault", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{B}"); super(ownerId, 78, "Spoils of the Vault", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{B}");
this.expansionSetCode = "MRD"; this.expansionSetCode = "MRD";
// Name a card. Reveal cards from the top of your library until you reveal the named card, then put that card into your hand. Exile all other cards revealed this way, and you lose 1 life for each of the exiled cards. // Name a card. Reveal cards from the top of your library until you reveal the named card, then put that card into your hand. Exile all other cards revealed this way, and you lose 1 life for each of the exiled cards.
this.getSpellAbility().addEffect(new NameACardEffect(NameACardEffect.TypeOfName.ALL)); this.getSpellAbility().addEffect(new NameACardEffect(NameACardEffect.TypeOfName.ALL));
this.getSpellAbility().addEffect(new SpoilsOfTheVaultEffect()); this.getSpellAbility().addEffect(new SpoilsOfTheVaultEffect());
@ -69,7 +68,6 @@ public class SpoilsOfTheVault extends CardImpl {
} }
} }
class SpoilsOfTheVaultEffect extends OneShotEffect { class SpoilsOfTheVaultEffect extends OneShotEffect {
public SpoilsOfTheVaultEffect() { public SpoilsOfTheVaultEffect() {
@ -94,28 +92,25 @@ class SpoilsOfTheVaultEffect extends OneShotEffect {
if (sourceObject == null || controller == null || cardName == null || cardName.isEmpty()) { if (sourceObject == null || controller == null || cardName == null || cardName.isEmpty()) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cardsToReveal = new CardsImpl();
Cards cardsToExile = new CardsImpl();
while (controller.getLibrary().size() > 0) { while (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game); Card card = controller.getLibrary().removeFromTop(game);
if (card != null) { if (card != null) {
cards.add(card); cardsToReveal.add(card);
if(card.getName().equals(cardName)){ if (card.getName().equals(cardName)) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
break; break;
} else {
cardsToExile.add(card);
} }
else{
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
}
}
else{
break;
} }
} }
controller.revealCards(sourceObject.getIdName(), cardsToReveal, game);
controller.revealCards(sourceObject.getName(), cards, game); controller.moveCards(cardsToExile, null, Zone.EXILED, source, game);
controller.loseLife(cards.size(), game); controller.loseLife(cardsToExile.size(), game);
return true; return true;
} }
} }

View file

@ -28,6 +28,7 @@
package mage.sets.modernmasters; package mage.sets.modernmasters;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
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;
@ -52,7 +53,6 @@ public class PetalsOfInsight extends CardImpl {
this.expansionSetCode = "MMA"; this.expansionSetCode = "MMA";
this.subtype.add("Arcane"); this.subtype.add("Arcane");
// Look at the top three cards of your library. You may put those cards on the bottom of your library in any order. If you do, return Petals of Insight to its owner's hand. Otherwise, draw three cards. // Look at the top three cards of your library. You may put those cards on the bottom of your library in any order. If you do, return Petals of Insight to its owner's hand. Otherwise, draw three cards.
this.getSpellAbility().addEffect(new PetalsOfInsightEffect()); this.getSpellAbility().addEffect(new PetalsOfInsightEffect());
} }
@ -85,33 +85,23 @@ class PetalsOfInsightEffect 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) { MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), 3); cards.addAll(controller.getLibrary().getTopCards(game, 3));
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game); controller.lookAtCards(sourceObject.getIdName(), cards, game);
if (card != null) { if (controller.chooseUse(outcome, "Put the cards on the bottom of your library in any order?", source, game)) {
cards.add(card); controller.putCardsOnBottomOfLibrary(cards, game, source, true);
}
}
player.lookAtCards("Petals of Insight", cards, game);
if (player.chooseUse(outcome, "Put the cards on the bottom of your library in any order?", source, game)) {
player.putCardsOnBottomOfLibrary(cards, game, source, true);
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
if (spellCard != null) { if (spellCard != null) {
player.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK); controller.moveCards(spellCard, null, Zone.HAND, source, game);
} }
} else { } else {
for (UUID cardId: cards) { controller.drawCards(3, game);
Card card = game.getCard(cardId);
if (card != null) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
}
player.drawCards(3, game);
} }
return true; return true;
} }

View file

@ -34,6 +34,8 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.ExileSpellEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.Cards;
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;
@ -56,7 +58,7 @@ public class AllSunsDawn extends CardImpl {
private final static FilterCard filterBlue = new FilterCard("blue card from your graveyard"); private final static FilterCard filterBlue = new FilterCard("blue card from your graveyard");
private final static FilterCard filterBlack = new FilterCard("black card from your graveyard"); private final static FilterCard filterBlack = new FilterCard("black card from your graveyard");
private final static FilterCard filterWhite = new FilterCard("white card from your graveyard"); private final static FilterCard filterWhite = new FilterCard("white card from your graveyard");
static { static {
filterGreen.add(new ColorPredicate(ObjectColor.GREEN)); filterGreen.add(new ColorPredicate(ObjectColor.GREEN));
filterRed.add(new ColorPredicate(ObjectColor.RED)); filterRed.add(new ColorPredicate(ObjectColor.RED));
@ -64,18 +66,18 @@ public class AllSunsDawn extends CardImpl {
filterBlack.add(new ColorPredicate(ObjectColor.BLACK)); filterBlack.add(new ColorPredicate(ObjectColor.BLACK));
filterWhite.add(new ColorPredicate(ObjectColor.WHITE)); filterWhite.add(new ColorPredicate(ObjectColor.WHITE));
} }
public AllSunsDawn(UUID ownerId) { public AllSunsDawn(UUID ownerId) {
super(ownerId, 138, "All Suns' Dawn", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{4}{G}"); super(ownerId, 138, "All Suns' Dawn", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{4}{G}");
this.expansionSetCode = "MM2"; this.expansionSetCode = "MM2";
// For each color, return up to one target card of that color from your graveyard to your hand. // For each color, return up to one target card of that color from your graveyard to your hand.
this.getSpellAbility().addEffect(new AllSunsDawnEffect()); this.getSpellAbility().addEffect(new AllSunsDawnEffect());
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0,1,filterGreen)); this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, filterGreen));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0,1,filterRed)); this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, filterRed));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0,1,filterBlue)); this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, filterBlue));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0,1,filterBlack)); this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, filterBlack));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0,1,filterWhite)); this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, filterWhite));
// Exile All Suns' Dawn. // Exile All Suns' Dawn.
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance()); this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
} }
@ -91,32 +93,34 @@ public class AllSunsDawn extends CardImpl {
} }
class AllSunsDawnEffect extends OneShotEffect { class AllSunsDawnEffect extends OneShotEffect {
public AllSunsDawnEffect() { public AllSunsDawnEffect() {
super(Outcome.ReturnToHand); super(Outcome.ReturnToHand);
this.staticText = "For each color, return up to one target card of that color from your graveyard to your hand. Exile {this}"; this.staticText = "For each color, return up to one target card of that color from your graveyard to your hand. Exile {this}";
} }
public AllSunsDawnEffect(final AllSunsDawnEffect effect) { public AllSunsDawnEffect(final AllSunsDawnEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public AllSunsDawnEffect copy() { public AllSunsDawnEffect copy() {
return new AllSunsDawnEffect(this); return new AllSunsDawnEffect(this);
} }
@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) {
for(Target target: source.getTargets()) { Cards cardsToHand = new CardsImpl();
for (Target target : source.getTargets()) {
UUID targetId = target.getFirstTarget(); UUID targetId = target.getFirstTarget();
Card card = game.getCard(targetId); Card card = game.getCard(targetId);
if (card != null) { if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD, true); cardsToHand.add(card);
} }
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true; return true;
} }
return false; return false;

View file

@ -28,14 +28,13 @@
package mage.sets.onslaught; package mage.sets.onslaught;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
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.constants.Outcome;
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.constants.Zone;
import mage.filter.common.FilterControlledLandPermanent; import mage.filter.common.FilterControlledLandPermanent;
import mage.game.Game; import mage.game.Game;
@ -55,7 +54,6 @@ public class ChainOfVapor extends CardImpl {
super(ownerId, 73, "Chain of Vapor", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{U}"); super(ownerId, 73, "Chain of Vapor", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{U}");
this.expansionSetCode = "ONS"; this.expansionSetCode = "ONS";
// Return target nonland permanent to its owner's hand. Then that permanent's controller may sacrifice a land. If the player does, he or she may copy this spell and may choose a new target for that copy. // Return target nonland permanent to its owner's hand. Then that permanent's controller may sacrifice a land. If the player does, he or she may copy this spell and may choose a new target for that copy.
this.getSpellAbility().addEffect(new ChainOfVaporEffect()); this.getSpellAbility().addEffect(new ChainOfVaporEffect());
this.getSpellAbility().addTarget(new TargetNonlandPermanent()); this.getSpellAbility().addTarget(new TargetNonlandPermanent());
@ -94,16 +92,14 @@ class ChainOfVaporEffect extends OneShotEffect {
} }
Permanent permanent = game.getPermanent(source.getFirstTarget()); Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) { if (permanent != null) {
if (!controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD)){ controller.moveCards(permanent, null, Zone.HAND, source, game);
return false;
}
Player player = game.getPlayer(permanent.getControllerId()); Player player = game.getPlayer(permanent.getControllerId());
if (player.chooseUse(Outcome.ReturnToHand, "Sacrifice a land to copy this spell?", source, game)){ if (player.chooseUse(Outcome.ReturnToHand, "Sacrifice a land to copy this spell?", source, game)) {
TargetControlledPermanent target = new TargetControlledPermanent(new FilterControlledLandPermanent()); TargetControlledPermanent target = new TargetControlledPermanent(new FilterControlledLandPermanent());
if (player.chooseTarget(Outcome.Sacrifice, target, source, game)){ if (player.chooseTarget(Outcome.Sacrifice, target, source, game)) {
Permanent land = game.getPermanent(target.getFirstTarget()); Permanent land = game.getPermanent(target.getFirstTarget());
if(land != null){ if (land != null) {
if(land.sacrifice(source.getSourceId(), game)){ if (land.sacrifice(source.getSourceId(), game)) {
Spell spell = game.getStack().getSpell(source.getSourceId()); Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) { if (spell != null) {
Spell copy = spell.copySpell(); Spell copy = spell.copySpell();
@ -123,9 +119,10 @@ class ChainOfVaporEffect extends OneShotEffect {
} }
} }
} }
return true;
} }
return true; return false;
} }
@Override @Override

View file

@ -30,9 +30,9 @@ package mage.sets.onslaught;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
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.CardImpl; import mage.cards.CardImpl;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
@ -55,7 +55,6 @@ public class WeirdHarvest extends CardImpl {
super(ownerId, 299, "Weird Harvest", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{G}{G}"); super(ownerId, 299, "Weird Harvest", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{G}{G}");
this.expansionSetCode = "ONS"; this.expansionSetCode = "ONS";
// Each player may search his or her library for up to X creature cards, reveal those cards, and put them into his or her hand. Then each player who searched his or her library this way shuffles it. // Each player may search his or her library for up to X creature cards, reveal those cards, and put them into his or her hand. Then each player who searched his or her library this way shuffles it.
getSpellAbility().addEffect(new WeirdHarvestEffect()); getSpellAbility().addEffect(new WeirdHarvestEffect());
} }
@ -89,20 +88,21 @@ class WeirdHarvestEffect 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) { MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
int xValue = source.getManaCostsToPay().getX(); int xValue = source.getManaCostsToPay().getX();
if (xValue > 0) { if (xValue > 0) {
List<Player> usingPlayers = new ArrayList<>(); List<Player> usingPlayers = new ArrayList<>();
this.chooseAndSearchLibrary(usingPlayers, controller, xValue, source, game); this.chooseAndSearchLibrary(usingPlayers, controller, xValue, source, sourceObject, game);
for (UUID playerId: controller.getInRange()) { for (UUID playerId : controller.getInRange()) {
if (!playerId.equals(controller.getId())) { if (!playerId.equals(controller.getId())) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
this.chooseAndSearchLibrary(usingPlayers, player, xValue, source, game); this.chooseAndSearchLibrary(usingPlayers, player, xValue, source, sourceObject, game);
} }
} }
} }
for (Player player: usingPlayers) { for (Player player : usingPlayers) {
player.shuffleLibrary(game); player.shuffleLibrary(game);
} }
return true; return true;
@ -111,21 +111,15 @@ class WeirdHarvestEffect extends OneShotEffect {
return false; return false;
} }
private void chooseAndSearchLibrary(List<Player> usingPlayers, Player player, int xValue, Ability source, Game game) { private void chooseAndSearchLibrary(List<Player> usingPlayers, Player player, int xValue, Ability source, MageObject sourceObject, Game game) {
if (player.chooseUse(Outcome.PutCardInPlay, "Search your library for up " + xValue + " creature cards and put them into your hand?", source, game)) { if (player.chooseUse(Outcome.PutCardInPlay, "Search your library for up " + xValue + " creature cards and put them into your hand?", source, game)) {
usingPlayers.add(player); usingPlayers.add(player);
TargetCardInLibrary target = new TargetCardInLibrary(0, xValue, new FilterCreatureCard()); TargetCardInLibrary target = new TargetCardInLibrary(0, xValue, new FilterCreatureCard());
if (player.searchLibrary(target, game)) { if (player.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) { if (target.getTargets().size() > 0) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(target.getTargets());
for (UUID cardId: (List<UUID>)target.getTargets()) { player.moveCards(cards, null, Zone.HAND, source, game);
Card card = player.getLibrary().getCard(cardId, game); player.revealCards(sourceObject.getIdName() + " (" + player.getName() + ")", cards, game);
if (card != null) {
cards.add(card);
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
}
}
player.revealCards("Weird Harvest", cards, game);
} }
} }
} }

View file

@ -34,61 +34,60 @@ import mage.util.CardUtil;
* @author nick.myers * @author nick.myers
*/ */
public class SkyshipWeatherlight extends CardImpl { public class SkyshipWeatherlight extends CardImpl {
public SkyshipWeatherlight(UUID ownerId) { public SkyshipWeatherlight(UUID ownerId) {
super(ownerId, 133, "Skyship Weatherlight", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{4}"); super(ownerId, 133, "Skyship Weatherlight", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{4}");
this.expansionSetCode = "PLS"; this.expansionSetCode = "PLS";
this.supertype.add("Legendary"); this.supertype.add("Legendary");
// When Skyship Weatherlight enters the battlefield, search your library for any number of artifact and/or creature cards and exile them. Then shuffle your library. // When Skyship Weatherlight enters the battlefield, search your library for any number of artifact and/or creature cards and exile them. Then shuffle your library.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SkyshipWeatherlightEffect(), false)); this.addAbility(new EntersBattlefieldTriggeredAbility(new SkyshipWeatherlightEffect(), false));
// {4}, {tap}, Choose a card at random that was removed from the game with Skyship Weatherlight. Put that card into your hand. // {4}, {tap}, Choose a card at random that was removed from the game with Skyship Weatherlight. Put that card into your hand.
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SkyshipWeatherlightEffect2(), new GenericManaCost(4)); SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SkyshipWeatherlightEffect2(), new GenericManaCost(4));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
this.addAbility(ability); this.addAbility(ability);
} }
public SkyshipWeatherlight(final SkyshipWeatherlight card) { public SkyshipWeatherlight(final SkyshipWeatherlight card) {
super(card); super(card);
} }
@Override @Override
public SkyshipWeatherlight copy() { public SkyshipWeatherlight copy() {
return new SkyshipWeatherlight(this); return new SkyshipWeatherlight(this);
} }
} }
class SkyshipWeatherlightEffect extends SearchEffect { class SkyshipWeatherlightEffect extends SearchEffect {
private static final FilterCard filter = new FilterCard("artifact and/or creature card"); private static final FilterCard filter = new FilterCard("artifact and/or creature card");
static { static {
filter.add(Predicates.or( filter.add(Predicates.or(
new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE))); new CardTypePredicate(CardType.CREATURE)));
} }
public SkyshipWeatherlightEffect() { public SkyshipWeatherlightEffect() {
super(new TargetCardInLibrary(0, Integer.MAX_VALUE, filter), Outcome.Neutral); super(new TargetCardInLibrary(0, Integer.MAX_VALUE, filter), Outcome.Neutral);
this.staticText = "search your library for any number of artifact and/or creature cards and remove them from the game. Then shuffle your library"; this.staticText = "search your library for any number of artifact and/or creature cards and remove them from the game. Then shuffle your library";
} }
public SkyshipWeatherlightEffect(final SkyshipWeatherlightEffect effect) { public SkyshipWeatherlightEffect(final SkyshipWeatherlightEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public SkyshipWeatherlightEffect copy() { public SkyshipWeatherlightEffect copy() {
return new SkyshipWeatherlightEffect(this); return new SkyshipWeatherlightEffect(this);
} }
@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());
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
@ -108,25 +107,25 @@ class SkyshipWeatherlightEffect extends SearchEffect {
} }
return false; return false;
} }
} }
class SkyshipWeatherlightEffect2 extends OneShotEffect { class SkyshipWeatherlightEffect2 extends OneShotEffect {
public SkyshipWeatherlightEffect2() { public SkyshipWeatherlightEffect2() {
super(Outcome.ReturnToHand); super(Outcome.ReturnToHand);
this.staticText = "Choose a card at random that was removed from the game with {this}. Put that card into your hand"; this.staticText = "Choose a card at random that was removed from the game with {this}. Put that card into your hand";
} }
public SkyshipWeatherlightEffect2(final SkyshipWeatherlightEffect2 effect) { public SkyshipWeatherlightEffect2(final SkyshipWeatherlightEffect2 effect) {
super(effect); super(effect);
} }
@Override @Override
public SkyshipWeatherlightEffect2 copy() { public SkyshipWeatherlightEffect2 copy() {
return new SkyshipWeatherlightEffect2(this); return new SkyshipWeatherlightEffect2(this);
} }
@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());
@ -134,12 +133,11 @@ class SkyshipWeatherlightEffect2 extends OneShotEffect {
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
ExileZone exZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter())); ExileZone exZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
if (exZone != null) { if (exZone != null) {
Card card = exZone.getRandom(game); controller.moveCards(exZone.getRandom(game), null, Zone.HAND, source, game);
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.EXILED);
} }
return true; return true;
} }
return false; return false;
} }
} }

View file

@ -57,6 +57,7 @@ import mage.target.TargetPermanent;
public class CloudstoneCurio extends CardImpl { public class CloudstoneCurio extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("a nonartifact permanent"); private static final FilterPermanent filter = new FilterPermanent("a nonartifact permanent");
static { static {
filter.add(Predicates.not(new CardTypePredicate(CardType.ARTIFACT))); filter.add(Predicates.not(new CardTypePredicate(CardType.ARTIFACT)));
filter.add(new ControllerPredicate(TargetController.YOU)); filter.add(new ControllerPredicate(TargetController.YOU));
@ -69,7 +70,6 @@ public class CloudstoneCurio extends CardImpl {
// Whenever a nonartifact permanent enters the battlefield under your control, you may return another permanent you control that shares a card type with it to its owner's hand. // Whenever a nonartifact permanent enters the battlefield under your control, you may return another permanent you control that shares a card type with it to its owner's hand.
this.addAbility(new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new CloudstoneCurioEffect(), filter, true, SetTargetPointer.PERMANENT, "", true)); this.addAbility(new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new CloudstoneCurioEffect(), filter, true, SetTargetPointer.PERMANENT, "", true));
} }
public CloudstoneCurio(final CloudstoneCurio card) { public CloudstoneCurio(final CloudstoneCurio card) {
@ -120,7 +120,7 @@ class CloudstoneCurioEffect extends OneShotEffect {
if (target.canChoose(controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) { if (target.canChoose(controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) {
Permanent returningCreature = game.getPermanent(target.getFirstTarget()); Permanent returningCreature = game.getPermanent(target.getFirstTarget());
if (returningCreature != null) { if (returningCreature != null) {
controller.moveCardToHandWithInfo(returningCreature, source.getSourceId(), game, Zone.BATTLEFIELD); controller.moveCards(returningCreature, null, Zone.HAND, source, game);
} }
} }
} }

View file

@ -28,10 +28,6 @@
package mage.sets.ravnica; package mage.sets.ravnica;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
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.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -40,8 +36,11 @@ 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.TargetController; import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -76,6 +75,7 @@ public class DarkConfidant extends CardImpl {
} }
class DarkConfidantEffect extends OneShotEffect { class DarkConfidantEffect extends OneShotEffect {
DarkConfidantEffect() { DarkConfidantEffect() {
super(Outcome.DrawCard); super(Outcome.DrawCard);
this.staticText = "reveal the top card of your library and put that card into your hand. You lose life equal to its converted mana cost"; this.staticText = "reveal the top card of your library and put that card into your hand. You lose life equal to its converted mana cost";
@ -87,17 +87,16 @@ class DarkConfidantEffect 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 sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player != null && sourcePermanent != null) { if (controller != null && sourcePermanent != null) {
if (player.getLibrary().size() > 0) { if (controller.getLibrary().size() > 0) {
Card card = player.getLibrary().removeFromTop(game); Card card = controller.getLibrary().removeFromTop(game);
if (card != null) { if (card != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card); controller.revealCards(sourcePermanent.getIdName(), cards, game);
player.revealCards(sourcePermanent.getName(), cards, game); controller.moveCards(card, null, Zone.HAND, source, game);
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.loseLife(card.getManaCost().convertedManaCost(), game);
player.loseLife(card.getManaCost().convertedManaCost(), game);
} }
return true; return true;

View file

@ -28,9 +28,6 @@
package mage.sets.returntoravnica; package mage.sets.returntoravnica;
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;
@ -38,7 +35,9 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.SacrificeSourceEffect; import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
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.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate; import mage.filter.predicate.permanent.AnotherPredicate;
@ -88,12 +87,12 @@ class FaerieImpostorEffect extends OneShotEffect {
filter.add(new AnotherPredicate()); filter.add(new AnotherPredicate());
} }
FaerieImpostorEffect ( ) { FaerieImpostorEffect() {
super(Outcome.ReturnToHand); super(Outcome.ReturnToHand);
staticText = effectText; staticText = effectText;
} }
FaerieImpostorEffect ( FaerieImpostorEffect effect ) { FaerieImpostorEffect(FaerieImpostorEffect effect) {
super(effect); super(effect);
} }
@ -108,13 +107,13 @@ class FaerieImpostorEffect extends OneShotEffect {
controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game); controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget()); Permanent permanent = game.getPermanent(target.getFirstTarget());
if ( permanent != null ) { if (permanent != null) {
targetChosen = true; targetChosen = true;
controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD); controller.moveCards(permanent, null, Zone.HAND, source, game);
} }
} }
if ( !targetChosen ) { if (!targetChosen) {
new SacrificeSourceEffect().apply(game, source); new SacrificeSourceEffect().apply(game, source);
} }
return true; return true;

View file

@ -258,7 +258,7 @@ class JaceArchitectOfThoughtEffect2 extends OneShotEffect {
for (UUID cardUuid : cardsToHand) { for (UUID cardUuid : cardsToHand) {
Card card = cardsToHand.get(cardUuid, game); Card card = cardsToHand.get(cardUuid, game);
if (card != null) { if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); player.moveCards(card, null, Zone.HAND, source, game);
} }
} }

View file

@ -99,13 +99,13 @@ class ElderPineOfJukaiEffect extends OneShotEffect {
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) { if (controller == null || sourceObject == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 3)); cards.addAll(controller.getLibrary().getTopCards(game, 3));
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getName(), cards, game);
for (Card card: cards.getCards(game)) { for (Card card : cards.getCards(game)) {
if (card.getCardType().contains(CardType.LAND)) { if (card.getCardType().contains(CardType.LAND)) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
cards.remove(card); cards.remove(card);
} }
} }

View file

@ -1,16 +1,16 @@
/* /*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * The views and conclusions contained in the software and documentation are those of the
* 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.
@ -28,6 +28,7 @@
package mage.sets.scarsofmirrodin; package mage.sets.scarsofmirrodin;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
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;
@ -55,7 +56,6 @@ public class CerebralEruption extends CardImpl {
super(ownerId, 86, "Cerebral Eruption", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{R}{R}"); super(ownerId, 86, "Cerebral Eruption", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{R}{R}");
this.expansionSetCode = "SOM"; this.expansionSetCode = "SOM";
// Target opponent reveals the top card of his or her library. Cerebral Eruption deals damage equal to the revealed card's converted mana cost to that player and each creature he or she controls. If a land card is revealed this way, return Cerebral Eruption to its owner's hand. // Target opponent reveals the top card of his or her library. Cerebral Eruption deals damage equal to the revealed card's converted mana cost to that player and each creature he or she controls. If a land card is revealed this way, return Cerebral Eruption to its owner's hand.
this.getSpellAbility().addTarget(new TargetOpponent()); this.getSpellAbility().addTarget(new TargetOpponent());
this.getSpellAbility().addEffect(new CerebralEruptionEffect()); this.getSpellAbility().addEffect(new CerebralEruptionEffect());
@ -87,21 +87,21 @@ class CerebralEruptionEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget()); Player player = game.getPlayer(source.getFirstTarget());
if (player != null && player.getLibrary().size() > 0) { MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null && sourceObject != null && player.getLibrary().size() > 0) {
Card card = player.getLibrary().getFromTop(game); Card card = player.getLibrary().getFromTop(game);
Cards cards = new CardsImpl(); Cards cards = new CardsImpl(card);
cards.add(card); player.revealCards(sourceObject.getIdName(), cards, game);
player.revealCards("Cerebral Eruption", cards, game);
game.getState().setValue(source.getSourceId().toString(), card); game.getState().setValue(source.getSourceId().toString(), card);
int damage = card.getManaCost().convertedManaCost(); int damage = card.getManaCost().convertedManaCost();
player.damage(damage, source.getSourceId(), game, false, true); player.damage(damage, source.getSourceId(), game, false, true);
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) { for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
perm.damage(damage, source.getSourceId(), game, false, true); perm.damage(damage, source.getSourceId(), game, false, true);
} }
if (card.getCardType().contains(CardType.LAND)) { if (card.getCardType().contains(CardType.LAND)) {
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
if (spellCard != null) { if (spellCard != null) {
player.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK); player.moveCards(spellCard, null, Zone.HAND, source, game);
} }
} }
return true; return true;

View file

@ -1,16 +1,16 @@
/* /*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * The views and conclusions contained in the software and documentation are those of the
* 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.
@ -50,7 +50,6 @@ public class PsychicMiasma extends CardImpl {
super(ownerId, 76, "Psychic Miasma", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{B}"); super(ownerId, 76, "Psychic Miasma", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{B}");
this.expansionSetCode = "SOM"; this.expansionSetCode = "SOM";
// Target player discards a card. If a land card is discarded this way, return Psychic Miasma to its owner's hand. // Target player discards a card. If a land card is discarded this way, return Psychic Miasma to its owner's hand.
this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addEffect(new PsychicMiasmaEffect()); this.getSpellAbility().addEffect(new PsychicMiasmaEffect());
@ -86,9 +85,10 @@ class PsychicMiasmaEffect extends OneShotEffect {
if (discardedCard != null && discardedCard.getCardType().contains(CardType.LAND)) { if (discardedCard != null && discardedCard.getCardType().contains(CardType.LAND)) {
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
if (spellCard != null) { if (spellCard != null) {
player.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK); player.moveCards(spellCard, null, Zone.HAND, source, game);
} }
} }
return true;
} }
return false; return false;
} }

View file

@ -100,7 +100,7 @@ class AdviceFromTheFaeEffect extends OneShotEffect {
for (Card card : cardsFromTopLibrary) { for (Card card : cardsFromTopLibrary) {
cards.add(card); cards.add(card);
} }
controller.lookAtCards(mageObject.getName(), cards, game); controller.lookAtCards(mageObject.getIdName(), cards, game);
int max = 0; int max = 0;
for (UUID playerId : controller.getInRange()) { for (UUID playerId : controller.getInRange()) {
FilterCreaturePermanent filter = new FilterCreaturePermanent(); FilterCreaturePermanent filter = new FilterCreaturePermanent();
@ -111,20 +111,11 @@ class AdviceFromTheFaeEffect extends OneShotEffect {
} }
} }
} }
if (game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), controller.getId(), game) > max) { boolean moreCreatures = game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), controller.getId(), game) > max;
TargetCard target = new TargetCard(2, Zone.LIBRARY, new FilterCard()); TargetCard target = new TargetCard(moreCreatures ? 2 : 1, Zone.LIBRARY, new FilterCard());
if (controller.choose(Outcome.DrawCard, cards, target, game)) { if (controller.choose(Outcome.DrawCard, cards, target, game)) {
controller.moveCardToHandWithInfo(game.getCard(target.getFirstTarget()), source.getSourceId(), game, Zone.LIBRARY); cards.removeAll(target.getTargets());
cards.remove(game.getCard(target.getFirstTarget())); controller.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game);
controller.moveCardToHandWithInfo(game.getCard(target.getTargets().get(1)), source.getSourceId(), game, Zone.LIBRARY);
cards.remove(game.getCard(target.getTargets().get(1)));
}
} else {
TargetCard target = new TargetCard(1, Zone.LIBRARY, new FilterCard());
if (controller.choose(Outcome.DrawCard, cards, target, game)) {
controller.moveCardToHandWithInfo(game.getCard(target.getFirstTarget()), source.getSourceId(), game, Zone.LIBRARY);
cards.remove(game.getCard(target.getFirstTarget()));
}
} }
controller.putCardsOnBottomOfLibrary(cards, game, source, true); controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true; return true;

View file

@ -50,7 +50,6 @@ public class AdNauseam extends CardImpl {
super(ownerId, 63, "Ad Nauseam", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{3}{B}{B}"); super(ownerId, 63, "Ad Nauseam", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{3}{B}{B}");
this.expansionSetCode = "ALA"; this.expansionSetCode = "ALA";
// Reveal the top card of your library and put that card into your hand. You lose life equal to its converted mana cost. You may repeat this process any number of times. // Reveal the top card of your library and put that card into your hand. You lose life equal to its converted mana cost. You may repeat this process any number of times.
this.getSpellAbility().addEffect(new AdNauseamEffect()); this.getSpellAbility().addEffect(new AdNauseamEffect());
} }
@ -92,12 +91,12 @@ class AdNauseamEffect extends OneShotEffect {
while (controller.chooseUse(outcome, message, source, game) && controller.getLibrary().size() > 0) { while (controller.chooseUse(outcome, message, source, game) && controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game); Card card = controller.getLibrary().removeFromTop(game);
if (card != null) { if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
int cmc = card.getManaCost().convertedManaCost(); int cmc = card.getManaCost().convertedManaCost();
if (cmc > 0) { if (cmc > 0) {
controller.loseLife(cmc, game); controller.loseLife(cmc, game);
} }
controller.revealCards(new StringBuilder(sourceCard.getName()).append(" put into hand").toString(), new CardsImpl(card), game); controller.revealCards(sourceCard.getIdName() + " put into hand", new CardsImpl(card), game);
} }
} }
return true; return true;

View file

@ -58,7 +58,6 @@ public class CruelUltimatum extends CardImpl {
super(ownerId, 164, "Cruel Ultimatum", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{U}{U}{B}{B}{B}{R}{R}"); super(ownerId, 164, "Cruel Ultimatum", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{U}{U}{B}{B}{B}{R}{R}");
this.expansionSetCode = "ALA"; this.expansionSetCode = "ALA";
// Target opponent sacrifices a creature, discards three cards, then loses 5 life. // Target opponent sacrifices a creature, discards three cards, then loses 5 life.
// You return a creature card from your graveyard to your hand, draw three cards, then gain 5 life. // You return a creature card from your graveyard to your hand, draw three cards, then gain 5 life.
this.getSpellAbility().addTarget(new TargetOpponent()); this.getSpellAbility().addTarget(new TargetOpponent());
@ -99,17 +98,17 @@ class CruelUltimatumEffect 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;
} }
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard")); TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard"));
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) { if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
if (card == null) { if (card == null) {
return false; return false;
} }
return player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD); controller.moveCards(card, null, Zone.HAND, source, game);
} }
return true; return true;
} }

View file

@ -69,9 +69,8 @@ public class TidehollowSculler extends CardImpl {
ability.addTarget(new TargetOpponent()); ability.addTarget(new TargetOpponent());
this.addAbility(ability); this.addAbility(ability);
// When Tidehollow Sculler leaves the battlefield, return the exiled card to its owner's hand. // When Tidehollow Sculler leaves the battlefield, return the exiled card to its owner's hand.
this.addAbility(new LeavesBattlefieldTriggeredAbility(new TidehollowScullerLeaveEffect(), false )); this.addAbility(new LeavesBattlefieldTriggeredAbility(new TidehollowScullerLeaveEffect(), false));
} }
public TidehollowSculler(final TidehollowSculler card) { public TidehollowSculler(final TidehollowSculler card) {
@ -124,7 +123,6 @@ class TidehollowScullerExileEffect extends OneShotEffect {
return false; return false;
} }
} }
class TidehollowScullerLeaveEffect extends OneShotEffect { class TidehollowScullerLeaveEffect extends OneShotEffect {
@ -148,17 +146,13 @@ class TidehollowScullerLeaveEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() -1; int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1;
ExileZone exZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter)); ExileZone exZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
if (exZone != null) { if (exZone != null) {
for (Card card : exZone.getCards(game)) { controller.moveCards(exZone, null, Zone.HAND, source, game);
if (card != null) { }
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.EXILED);
}
}
}
return true; return true;
} }
return false; return false;
} }
} }

View file

@ -28,6 +28,7 @@
package mage.sets.tenthedition; package mage.sets.tenthedition;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
@ -94,35 +95,35 @@ class AbundanceReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player player = game.getPlayer(event.getPlayerId()); Player controller = game.getPlayer(event.getPlayerId());
if (player != null) { MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
FilterCard filter = new FilterCard(); FilterCard filter = new FilterCard();
if (player.chooseUse(Outcome.Benefit, "Choose land? (No = nonland)", source, game)) { if (controller.chooseUse(Outcome.Benefit, "Choose land? (No = nonland)", source, game)) {
filter.add(new CardTypePredicate(CardType.LAND)); filter.add(new CardTypePredicate(CardType.LAND));
} } else {
else {
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND))); filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
while (player.getLibrary().size() > 0) { while (controller.getLibrary().size() > 0) {
Card card = player.getLibrary().removeFromTop(game); Card card = controller.getLibrary().removeFromTop(game);
if (filter.match(card, source.getSourceId(), source.getControllerId(), game)) { if (filter.match(card, source.getSourceId(), source.getControllerId(), game)) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); controller.moveCards(card, null, Zone.HAND, source, game);
break; break;
} }
cards.add(card); cards.add(card);
} }
player.revealCards("Abundance", cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
player.putCardsOnBottomOfLibrary(cards, game, source, true); controller.putCardsOnBottomOfLibrary(cards, game, source, true);
} }
return true; return true;
} }
@Override @Override
public boolean checksEventType(GameEvent event, Game game) { public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DRAW_CARD; return event.getType() == GameEvent.EventType.DRAW_CARD;
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getPlayerId().equals(source.getControllerId())) { if (event.getPlayerId().equals(source.getControllerId())) {
@ -133,4 +134,4 @@ class AbundanceReplacementEffect extends ReplacementEffectImpl {
} }
return false; return false;
} }
} }

View file

@ -71,7 +71,7 @@ public class MesmericFiend extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// When Mesmeric Fiend leaves the battlefield, return the exiled card to its owner's hand. // When Mesmeric Fiend leaves the battlefield, return the exiled card to its owner's hand.
this.addAbility(new LeavesBattlefieldTriggeredAbility(new MesmericFiendLeaveEffect(), false )); this.addAbility(new LeavesBattlefieldTriggeredAbility(new MesmericFiendLeaveEffect(), false));
} }
public MesmericFiend(final MesmericFiend card) { public MesmericFiend(final MesmericFiend card) {
@ -83,6 +83,7 @@ public class MesmericFiend extends CardImpl {
return new MesmericFiend(this); return new MesmericFiend(this);
} }
} }
class MesmericFiendExileEffect extends OneShotEffect { class MesmericFiendExileEffect extends OneShotEffect {
public MesmericFiendExileEffect() { public MesmericFiendExileEffect() {
@ -120,7 +121,6 @@ class MesmericFiendExileEffect extends OneShotEffect {
return false; return false;
} }
} }
class MesmericFiendLeaveEffect extends OneShotEffect { class MesmericFiendLeaveEffect extends OneShotEffect {
@ -143,18 +143,13 @@ class MesmericFiendLeaveEffect 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());
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject !=null) { if (controller != null && sourceObject != null) {
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() -1; int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1;
ExileZone exZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter)); ExileZone exZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
if (exZone != null) { if (exZone != null) {
for (Card card : exZone.getCards(game)) { return controller.moveCards(exZone, null, Zone.HAND, source, game);
if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.EXILED);
}
}
return true;
} }
} }
return false; return false;
} }
} }

View file

@ -32,8 +32,8 @@ import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.ExileSpellEffect;
import mage.abilities.effects.common.discard.DiscardHandAllEffect; import mage.abilities.effects.common.discard.DiscardHandAllEffect;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
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;
@ -54,13 +54,12 @@ public class IllGottenGains extends CardImpl {
super(ownerId, 138, "Ill-Gotten Gains", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{B}{B}"); super(ownerId, 138, "Ill-Gotten Gains", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{B}{B}");
this.expansionSetCode = "USG"; this.expansionSetCode = "USG";
// Exile Ill-Gotten Gains. // Exile Ill-Gotten Gains.
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance()); this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
// Each player discards his or her hand, // Each player discards his or her hand,
this.getSpellAbility().addEffect(new DiscardHandAllEffect()); this.getSpellAbility().addEffect(new DiscardHandAllEffect());
//then returns up to three cards from his or her graveyard to his or her hand. //then returns up to three cards from his or her graveyard to his or her hand.
this.getSpellAbility().addEffect(new IllGottenGainsEffect()); this.getSpellAbility().addEffect(new IllGottenGainsEffect());
} }
@ -76,34 +75,31 @@ public class IllGottenGains extends CardImpl {
} }
class IllGottenGainsEffect extends OneShotEffect { class IllGottenGainsEffect extends OneShotEffect {
IllGottenGainsEffect() { IllGottenGainsEffect() {
super(Outcome.ReturnToHand); super(Outcome.ReturnToHand);
this.staticText = ", then returns up to three cards from his or her graveyard to his or her hand."; this.staticText = ", then returns up to three cards from his or her graveyard to his or her hand.";
} }
IllGottenGainsEffect(final IllGottenGainsEffect effect) { IllGottenGainsEffect(final IllGottenGainsEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public IllGottenGainsEffect copy() { public IllGottenGainsEffect copy() {
return new IllGottenGainsEffect(this); return new IllGottenGainsEffect(this);
} }
@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) {
for (UUID playerId : controller.getInRange()){ for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
Target target = new TargetCardInYourGraveyard(0, 3, new FilterCard()); Target target = new TargetCardInYourGraveyard(0, 3, new FilterCard());
if (target.choose(Outcome.ReturnToHand, player.getId(), source.getSourceId(), game)) { if (target.choose(Outcome.ReturnToHand, player.getId(), source.getSourceId(), game)) {
for (UUID targetId : target.getTargets()) { controller.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game);
Card card = game.getCard(targetId);
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
}
} }
} }
} }

View file

@ -35,6 +35,8 @@ import mage.abilities.costs.common.SacrificeSourceCost;
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.cards.Cards;
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;
@ -86,22 +88,20 @@ class NoRestForTheWickedEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
NoRestForTheWickedWatcher watcher = (NoRestForTheWickedWatcher) game.getState().getWatchers().get("NoRestForTheWickedWatcher"); NoRestForTheWickedWatcher watcher = (NoRestForTheWickedWatcher) game.getState().getWatchers().get("NoRestForTheWickedWatcher");
if (watcher != null) { Player controller = game.getPlayer(source.getControllerId());
if (watcher != null && controller != null) {
Cards cardsToHand = new CardsImpl();
for (UUID cardId : watcher.cards) { for (UUID cardId : watcher.cards) {
Card c = game.getCard(cardId); Card c = game.getCard(cardId);
if (c != null) { if (c != null) {
if (game.getState().getZone(cardId) == Zone.GRAVEYARD if (game.getState().getZone(cardId) == Zone.GRAVEYARD
&& c.getCardType().contains(CardType.CREATURE) && c.getCardType().contains(CardType.CREATURE)
&& c.getOwnerId().equals(source.getControllerId())) { && c.getOwnerId().equals(source.getControllerId())) {
//400.3 cardsToHand.add(c);
Player p = game.getPlayer(source.getControllerId());
if (p != null) {
p.moveCardToHandWithInfo(c, source.getSourceId(), game, Zone.GRAVEYARD);
}
return false;
} }
} }
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true; return true;
} }
return false; return false;

View file

@ -1,16 +1,16 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,12 +20,11 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * The views and conclusions contained in the software and documentation are those of the
* 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.zendikar; package mage.sets.zendikar;
import java.util.UUID; import java.util.UUID;
@ -108,10 +107,10 @@ class GoblinGuideTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.getSourceId()) ) { if (event.getSourceId().equals(this.getSourceId())) {
UUID defenderId = game.getCombat().getDefendingPlayerId(getSourceId(), game); UUID defenderId = game.getCombat().getDefendingPlayerId(getSourceId(), game);
if (defenderId != null) { if (defenderId != null) {
for (Effect effect :this.getEffects()) { for (Effect effect : this.getEffects()) {
// set here because attacking creature can be removed until effect resolves // set here because attacking creature can be removed until effect resolves
effect.setTargetPointer(new FixedTarget(defenderId)); effect.setTargetPointer(new FixedTarget(defenderId));
} }
@ -134,8 +133,8 @@ class GoblinGuideTriggeredAbility extends TriggeredAbilityImpl {
return new GoblinGuideTriggeredAbility(this); return new GoblinGuideTriggeredAbility(this);
} }
} }
class GoblinGuideEffect extends OneShotEffect { class GoblinGuideEffect extends OneShotEffect {
public GoblinGuideEffect() { public GoblinGuideEffect() {
@ -153,7 +152,7 @@ class GoblinGuideEffect extends OneShotEffect {
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player defender = game.getPlayer(getTargetPointer().getFirst(game, source)); Player defender = game.getPlayer(getTargetPointer().getFirst(game, source));
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && defender != null) { if (sourceObject != null && defender != null) {
@ -163,7 +162,7 @@ class GoblinGuideEffect extends OneShotEffect {
cards.add(card); cards.add(card);
defender.revealCards(sourceObject.getName(), cards, game); defender.revealCards(sourceObject.getName(), cards, game);
if (card.getCardType().contains(CardType.LAND)) { if (card.getCardType().contains(CardType.LAND)) {
defender.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); defender.moveCards(card, null, Zone.HAND, source, game);
} }
} }
return true; return true;
@ -171,4 +170,4 @@ class GoblinGuideEffect extends OneShotEffect {
return false; return false;
} }
} }

View file

@ -0,0 +1,58 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.test.cards.triggers.combat.damage;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class GravebladeMarauderTest extends CardTestPlayerBase {
@Test
public void testTwoAttackers() {
addCard(Zone.GRAVEYARD, playerB, "Silvercoat Lion", 3);
// Whenever Graveblade Marauder deals combat damage to a player, that player loses life equal to the number of creature cards in your graveyard.
addCard(Zone.BATTLEFIELD, playerB, "Graveblade Marauder", 2);// 1/4
attack(2, playerB, "Graveblade Marauder");
attack(2, playerB, "Graveblade Marauder");
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerA, 12); // 1 + 3 + 1 + 3 = 8
assertLife(playerB, 20);
}
}

View file

@ -1693,13 +1693,13 @@ public class TestPlayer implements Player {
} }
@Override @Override
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) { public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game) {
return computerPlayer.moveCardToHandWithInfo(card, sourceId, game, fromZone); return computerPlayer.moveCardToHandWithInfo(card, sourceId, game);
} }
@Override @Override
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean withName) { public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, boolean withName) {
return computerPlayer.moveCardToHandWithInfo(card, sourceId, game, fromZone, withName); return computerPlayer.moveCardToHandWithInfo(card, sourceId, game, withName);
} }
@Override @Override

View file

@ -1,16 +1,16 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,22 +20,19 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * The views and conclusions contained in the software and documentation are those of the
* 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.abilities.costs.common; package mage.abilities.costs.common;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.CostImpl; import mage.abilities.costs.CostImpl;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
/** /**
@ -52,6 +49,7 @@ public class ReturnToHandFromGraveyardCost extends CostImpl {
this.text = new StringBuilder("return ").append(target.getTargetName()).append(" from graveyard to it's owner's hand").toString(); this.text = new StringBuilder("return ").append(target.getTargetName()).append(" from graveyard to it's owner's hand").toString();
} }
} }
public ReturnToHandFromGraveyardCost(ReturnToHandFromGraveyardCost cost) { public ReturnToHandFromGraveyardCost(ReturnToHandFromGraveyardCost cost) {
super(cost); super(cost);
} }
@ -61,12 +59,12 @@ public class ReturnToHandFromGraveyardCost extends CostImpl {
Player controller = game.getPlayer(controllerId); Player controller = game.getPlayer(controllerId);
if (controller != null) { if (controller != null) {
if (targets.choose(Outcome.ReturnToHand, controllerId, sourceId, game)) { if (targets.choose(Outcome.ReturnToHand, controllerId, sourceId, game)) {
for (UUID targetId: targets.get(0).getTargets()) { for (UUID targetId : targets.get(0).getTargets()) {
mage.cards.Card targetCard = game.getCard(targetId); mage.cards.Card targetCard = game.getCard(targetId);
if (targetCard == null) { if (targetCard == null) {
return false; return false;
} }
paid |= controller.moveCardToHandWithInfo(targetCard, sourceId, game, Zone.HAND); paid |= controller.moveCardToHandWithInfo(targetCard, sourceId, game);
} }
} }
} }

View file

@ -25,14 +25,12 @@
* 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.abilities.costs.common; package mage.abilities.costs.common;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.CostImpl; import mage.abilities.costs.CostImpl;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -62,12 +60,12 @@ public class ReturnToHandTargetPermanentCost extends CostImpl {
Player controller = game.getPlayer(controllerId); Player controller = game.getPlayer(controllerId);
if (controller != null) { if (controller != null) {
if (targets.choose(Outcome.ReturnToHand, controllerId, sourceId, game)) { if (targets.choose(Outcome.ReturnToHand, controllerId, sourceId, game)) {
for (UUID targetId: targets.get(0).getTargets()) { for (UUID targetId : targets.get(0).getTargets()) {
Permanent permanent = game.getPermanent(targetId); Permanent permanent = game.getPermanent(targetId);
if (permanent == null) { if (permanent == null) {
return false; return false;
} }
paid |= controller.moveCardToHandWithInfo(permanent, sourceId, game, Zone.HAND); paid |= controller.moveCardToHandWithInfo(permanent, sourceId, game);
} }
} }
} }
@ -84,5 +82,4 @@ public class ReturnToHandTargetPermanentCost extends CostImpl {
return new ReturnToHandTargetPermanentCost(this); return new ReturnToHandTargetPermanentCost(this);
} }
} }

View file

@ -60,7 +60,7 @@ public class ClashWinReturnToHandSpellEffect extends OneShotEffect implements Ma
if (ClashEffect.getInstance().apply(game, source)) { if (ClashEffect.getInstance().apply(game, source)) {
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
if (spellCard != null) { if (spellCard != null) {
controller.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK); controller.moveCards(spellCard, null, Zone.HAND, source, game);
} }
} }
return true; return true;

View file

@ -71,18 +71,20 @@ public class EnvoyEffect 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());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if(controller == null || sourceObject == null) { if (controller == null || sourceObject == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, numCards)); cards.addAll(controller.getLibrary().getTopCards(game, numCards));
controller.revealCards(sourceObject.getName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);
for(Card card: cards.getCards(game)) { Cards cardsToHand = new CardsImpl();
if(filter.match(card, game)) { for (Card card : cards.getCards(game)) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); if (filter.match(card, game)) {
cards.remove(card); cardsToHand.add(card);
} }
} }
cards.removeAll(cardsToHand);
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
controller.putCardsOnBottomOfLibrary(cards, game, source, true); controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true; return true;
} }
@ -94,6 +96,6 @@ public class EnvoyEffect extends OneShotEffect {
} }
return "Reveal the top " + CardUtil.numberToText(numCards) + " cards of your library. Put all " return "Reveal the top " + CardUtil.numberToText(numCards) + " cards of your library. Put all "
+ filter.getMessage() + " revealed this way into your hand and the rest on the bottom of your library in any order."; + filter.getMessage() + " revealed this way into your hand and the rest on the bottom of your library in any order.";
} }
} }

View file

@ -1,16 +1,16 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,19 +20,17 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * The views and conclusions contained in the software and documentation are those of the
* 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.abilities.effects.common; package mage.abilities.effects.common;
import java.util.UUID;
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.CardsImpl;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
@ -61,16 +59,11 @@ public class ReturnFromGraveyardToHandTargetEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
for (UUID cardId: getTargetPointer().getTargets(game, source)) { Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(cardId); if (controller != null) {
if (card != null && game.getState().getZone(cardId).equals(Zone.GRAVEYARD)) { return controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)), null, Zone.HAND, source, game);
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
}
}
} }
return true; return false;
} }
@Override @Override
@ -79,14 +72,14 @@ public class ReturnFromGraveyardToHandTargetEffect extends OneShotEffect {
return staticText; return staticText;
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
Target target = mode.getTargets().get(0); Target target = mode.getTargets().get(0);
sb.append("return "); sb.append("return ");
if (target.getMaxNumberOfTargets() > 1) { if (target.getMaxNumberOfTargets() > 1) {
if (target.getMaxNumberOfTargets() != target.getNumberOfTargets()) { if (target.getMaxNumberOfTargets() != target.getNumberOfTargets()) {
sb.append("up to "); sb.append("up to ");
} }
sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" "); sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" ");
} }
if (!mode.getTargets().get(0).getTargetName().startsWith("another")) { if (!mode.getTargets().get(0).getTargetName().startsWith("another")) {
sb.append("target "); sb.append("target ");
} }

View file

@ -1,16 +1,16 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,12 +20,11 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * The views and conclusions contained in the software and documentation are those of the
* 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.abilities.effects.common; package mage.abilities.effects.common;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -61,7 +60,7 @@ public class ReturnSourceFromGraveyardToHandEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Card card = controller.getGraveyard().get(source.getSourceId(), game); Card card = controller.getGraveyard().get(source.getSourceId(), game);
if (card != null) { if (card != null) {
return controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD); return controller.moveCards(card, null, Zone.HAND, source, game);
} }
return false; return false;
} }

View file

@ -25,11 +25,12 @@
* 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.abilities.effects.common; package mage.abilities.effects.common;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
@ -41,12 +42,10 @@ import mage.players.Player;
* *
* @author Plopman * @author Plopman
*/ */
public class ReturnToHandFromBattlefieldAllEffect extends OneShotEffect { public class ReturnToHandFromBattlefieldAllEffect extends OneShotEffect {
private final FilterPermanent filter; private final FilterPermanent filter;
public ReturnToHandFromBattlefieldAllEffect(FilterPermanent filter) { public ReturnToHandFromBattlefieldAllEffect(FilterPermanent filter) {
super(Outcome.ReturnToHand); super(Outcome.ReturnToHand);
this.filter = filter; this.filter = filter;
@ -62,9 +61,11 @@ public class ReturnToHandFromBattlefieldAllEffect 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) {
Cards cardsToHand = new CardsImpl();
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD); cardsToHand.add(permanent);
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true; return true;
} }
return false; return false;

View file

@ -1,16 +1,16 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * The views and conclusions contained in the software and documentation are those of the
* 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.
@ -45,20 +45,23 @@ import mage.players.Player;
public class ReturnToHandSourceEffect extends OneShotEffect { public class ReturnToHandSourceEffect extends OneShotEffect {
boolean fromBattlefieldOnly; boolean fromBattlefieldOnly;
boolean returnFromNextZone ; boolean returnFromNextZone;
public ReturnToHandSourceEffect() { public ReturnToHandSourceEffect() {
this(false); this(false);
} }
public ReturnToHandSourceEffect(boolean fromBattlefieldOnly) { public ReturnToHandSourceEffect(boolean fromBattlefieldOnly) {
this(fromBattlefieldOnly, false); this(fromBattlefieldOnly, false);
} }
/** /**
* *
* @param fromBattlefieldOnly the object is only returned if it's on the battlefield as the effect resolves * @param fromBattlefieldOnly the object is only returned if it's on the
* @param returnFromNextZone the object is only returned, if it has changed the zone one time after the source ability triggered or was activated (e.g. Angelic Destiny) * battlefield as the effect resolves
* @param returnFromNextZone the object is only returned, if it has changed
* the zone one time after the source ability triggered or was activated
* (e.g. Angelic Destiny)
*/ */
public ReturnToHandSourceEffect(boolean fromBattlefieldOnly, boolean returnFromNextZone) { public ReturnToHandSourceEffect(boolean fromBattlefieldOnly, boolean returnFromNextZone) {
super(Outcome.ReturnToHand); super(Outcome.ReturnToHand);
@ -83,8 +86,8 @@ public class ReturnToHandSourceEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
MageObject mageObject; MageObject mageObject;
if (returnFromNextZone && if (returnFromNextZone
game.getState().getZoneChangeCounter(source.getSourceId()) == source.getSourceObjectZoneChangeCounter() + 1) { && game.getState().getZoneChangeCounter(source.getSourceId()) == source.getSourceObjectZoneChangeCounter() + 1) {
mageObject = game.getObject(source.getSourceId()); mageObject = game.getObject(source.getSourceId());
} else { } else {
mageObject = source.getSourceObjectIfItStillExists(game); mageObject = source.getSourceObjectIfItStillExists(game);
@ -94,13 +97,13 @@ public class ReturnToHandSourceEffect extends OneShotEffect {
case BATTLEFIELD: case BATTLEFIELD:
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
return controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD); return controller.moveCards(permanent, null, Zone.HAND, source, game);
} }
break; break;
case GRAVEYARD: case GRAVEYARD:
Card card = (Card) mageObject; Card card = (Card) mageObject;
if (!fromBattlefieldOnly) { if (!fromBattlefieldOnly) {
return controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD); return controller.moveCards(card, null, Zone.HAND, source, game);
} }
} }
} }

View file

@ -31,7 +31,7 @@ public class ReturnToHandSpellEffect extends OneShotEffect implements MageSingle
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard(); Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
controller.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK); controller.moveCards(spellCard, null, Zone.HAND, source, game);
return true; return true;
} }
return false; return false;

View file

@ -28,11 +28,13 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import java.util.Set; import java.util.Set;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; 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;
@ -45,7 +47,6 @@ import mage.util.CardUtil;
* *
* @author LevelX * @author LevelX
*/ */
public class RevealLibraryPutIntoHandEffect extends OneShotEffect { public class RevealLibraryPutIntoHandEffect extends OneShotEffect {
private DynamicValue amountCards; private DynamicValue amountCards;
@ -78,27 +79,26 @@ public class RevealLibraryPutIntoHandEffect 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) { MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false; return false;
} }
CardsImpl cards = new CardsImpl(); CardsImpl cards = new CardsImpl();
int amount = Math.min(amountCards.calculate(game, source, this), player.getLibrary().size()); cards.addAll(controller.getLibrary().getTopCards(game, amountCards.calculate(game, source, this)));
for (int i = 0; i < amount; i++) { controller.revealCards(sourceObject.getIdName(), cards, game);
cards.add(player.getLibrary().removeFromTop(game));
}
player.revealCards(new StringBuilder("Put ").append(filter.getMessage()).append(" into hand").toString(), cards, game);
Set<Card> cardsList = cards.getCards(game); Set<Card> cardsList = cards.getCards(game);
Cards cardsToHand = new CardsImpl();
for (Card card : cardsList) { for (Card card : cardsList) {
if (filter.match(card, game)) { if (filter.match(card, game)) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); cardsToHand.add(card);
cards.remove(card); cards.remove(card);
} }
} }
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
player.putCardsOnBottomOfLibrary(cards, game, source, anyOrder); controller.putCardsOnBottomOfLibrary(cards, game, source, anyOrder);
return true; return true;
} }

View file

@ -134,7 +134,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
Cards revealedCards = new CardsImpl(Zone.HAND); Cards revealedCards = new CardsImpl(Zone.HAND);
numberToReveal = Math.min(player.getHand().size(), numberToReveal); numberToReveal = Math.min(player.getHand().size(), numberToReveal);
if (player.getHand().size() > numberToReveal) { if (player.getHand().size() > numberToReveal) {
TargetCardInHand chosenCards = new TargetCardInHand(numberToReveal, numberToReveal, new FilterCard("card in "+ player.getLogName() +"'s hand")); TargetCardInHand chosenCards = new TargetCardInHand(numberToReveal, numberToReveal, new FilterCard("card in " + player.getLogName() + "'s hand"));
chosenCards.setNotTarget(true); chosenCards.setNotTarget(true);
if (chosenCards.canChoose(player.getId(), game) && player.chooseTarget(Outcome.Discard, player.getHand(), chosenCards, source, game)) { if (chosenCards.canChoose(player.getId(), game) && player.chooseTarget(Outcome.Discard, player.getHand(), chosenCards, source, game)) {
if (!chosenCards.getTargets().isEmpty()) { if (!chosenCards.getTargets().isEmpty()) {
@ -151,7 +151,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
revealedCards.addAll(player.getHand()); revealedCards.addAll(player.getHand());
} }
player.revealCards(sourceCard != null ? sourceCard.getName() :"Discard", revealedCards, game); player.revealCards(sourceCard != null ? sourceCard.getIdName() + " (" + sourceCard.getZoneChangeCounter(game) + ")" : "Discard", revealedCards, game);
boolean result = true; boolean result = true;
int filteredCardsCount = revealedCards.count(filter, source.getSourceId(), source.getControllerId(), game); int filteredCardsCount = revealedCards.count(filter, source.getSourceId(), source.getControllerId(), game);
@ -183,7 +183,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
private String setText() { private String setText() {
StringBuilder sb = new StringBuilder("Target "); StringBuilder sb = new StringBuilder("Target ");
switch(targetController) { switch (targetController) {
case OPPONENT: case OPPONENT:
sb.append("opponent"); sb.append("opponent");
break; break;

View file

@ -93,14 +93,12 @@ public class SearchLibraryPutInHandEffect extends SearchEffect {
if (target.getTargets().size() > 0) { if (target.getTargets().size() > 0) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
for (UUID cardId : target.getTargets()) { for (UUID cardId : target.getTargets()) {
Card card = controller.getLibrary().remove(cardId, game); Card card = game.getCard(cardId);
if (card != null) { if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, revealCards); cards.add(card);
if (revealCards) {
cards.add(card);
}
} }
} }
controller.moveCards(cards, null, Zone.HAND, source, game);
if (revealCards) { if (revealCards) {
String name = "Reveal"; String name = "Reveal";
Card sourceCard = game.getCard(source.getSourceId()); Card sourceCard = game.getCard(source.getSourceId());

View file

@ -27,16 +27,15 @@
*/ */
package mage.abilities.effects.keyword; package mage.abilities.effects.keyword;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.CardsImpl;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledLandPermanent; import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.Target; import mage.target.Target;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
@ -53,7 +52,7 @@ public class SweepEffect extends OneShotEffect {
public SweepEffect(String sweepSubtype) { public SweepEffect(String sweepSubtype) {
super(Outcome.Benefit); super(Outcome.Benefit);
this.sweepSubtype = sweepSubtype; this.sweepSubtype = sweepSubtype;
this.staticText = "<i>Sweep</i> - Return any number of "+ sweepSubtype + (sweepSubtype.endsWith("s") ? "":"s") + " you control to their owner's hand"; this.staticText = "<i>Sweep</i> - Return any number of " + sweepSubtype + (sweepSubtype.endsWith("s") ? "" : "s") + " you control to their owner's hand";
} }
public SweepEffect(final SweepEffect effect) { public SweepEffect(final SweepEffect effect) {
@ -75,10 +74,7 @@ public class SweepEffect extends OneShotEffect {
Target target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); Target target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true);
if (controller.chooseTarget(outcome, target, source, game)) { if (controller.chooseTarget(outcome, target, source, game)) {
game.getState().setValue(CardUtil.getCardZoneString("sweep", source.getSourceId(), game), target.getTargets().size()); game.getState().setValue(CardUtil.getCardZoneString("sweep", source.getSourceId(), game), target.getTargets().size());
for (UUID uuid : target.getTargets()) { controller.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game);
Permanent land = game.getPermanent(uuid);
controller.moveCardToHandWithInfo(land, source.getSourceId(), game, Zone.HAND);
}
} }
return true; return true;
} }

View file

@ -1,31 +1,30 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * The views and conclusions contained in the software and documentation are those of the
* 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.abilities.keyword; package mage.abilities.keyword;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -48,21 +47,21 @@ import mage.target.common.TargetCardInHand;
* @author Mael * @author Mael
*/ */
public class AuraSwapAbility extends ActivatedAbilityImpl { public class AuraSwapAbility extends ActivatedAbilityImpl {
public AuraSwapAbility(ManaCost manaCost) { public AuraSwapAbility(ManaCost manaCost) {
super(Zone.BATTLEFIELD, new AuraSwapEffect(), manaCost); super(Zone.BATTLEFIELD, new AuraSwapEffect(), manaCost);
} }
public AuraSwapAbility(final AuraSwapAbility ability) { public AuraSwapAbility(final AuraSwapAbility ability) {
super(ability); super(ability);
} }
@Override @Override
public AuraSwapAbility copy() { public AuraSwapAbility copy() {
return new AuraSwapAbility(this); return new AuraSwapAbility(this);
} }
@Override @Override
public String getRule() { public String getRule() {
return new StringBuilder("Aura swap ").append(getManaCostsToPay().getText()).append(" <i>(") return new StringBuilder("Aura swap ").append(getManaCostsToPay().getText()).append(" <i>(")
@ -72,42 +71,42 @@ public class AuraSwapAbility extends ActivatedAbilityImpl {
} }
class AuraSwapEffect extends OneShotEffect { class AuraSwapEffect extends OneShotEffect {
private static final FilterCard filter = new FilterCard(); private static final FilterCard filter = new FilterCard();
static { static {
filter.add(new SubtypePredicate("Aura")); filter.add(new SubtypePredicate("Aura"));
} }
AuraSwapEffect() { AuraSwapEffect() {
super(Outcome.PutCardInPlay); super(Outcome.PutCardInPlay);
this.staticText = "Exchange this Aura with an Aura card in your hand."; this.staticText = "Exchange this Aura with an Aura card in your hand.";
} }
AuraSwapEffect(final AuraSwapEffect effect) { AuraSwapEffect(final AuraSwapEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public AuraSwapEffect copy() { public AuraSwapEffect copy() {
return new AuraSwapEffect(this); return new AuraSwapEffect(this);
} }
@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) {
Permanent auraPermanent = game.getPermanent(source.getSourceId()); Permanent auraPermanent = game.getPermanent(source.getSourceId());
if (auraPermanent != null && auraPermanent.getSubtype().contains("Aura") && auraPermanent.getOwnerId().equals(source.getControllerId())) { if (auraPermanent != null && auraPermanent.getSubtype().contains("Aura") && auraPermanent.getOwnerId().equals(source.getControllerId())) {
Permanent enchantedPermanent = game.getPermanent(auraPermanent.getAttachedTo()); Permanent enchantedPermanent = game.getPermanent(auraPermanent.getAttachedTo());
filter.add(new AuraCardCanAttachToPermanentId(enchantedPermanent.getId())); filter.add(new AuraCardCanAttachToPermanentId(enchantedPermanent.getId()));
TargetCardInHand target = new TargetCardInHand(0, 1, filter); TargetCardInHand target = new TargetCardInHand(0, 1, filter);
if (player.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
Card auraInHand = game.getCard(target.getFirstTarget()); Card auraInHand = game.getCard(target.getFirstTarget());
if (auraInHand != null) { if (auraInHand != null) {
player.putOntoBattlefieldWithInfo(auraInHand, game, Zone.HAND, source.getSourceId()); controller.putOntoBattlefieldWithInfo(auraInHand, game, Zone.HAND, source.getSourceId());
enchantedPermanent.addAttachment(auraInHand.getId(), game); enchantedPermanent.addAttachment(auraInHand.getId(), game);
player.moveCardToHandWithInfo(auraPermanent, source.getSourceId(), game, Zone.BATTLEFIELD); controller.moveCards(auraPermanent, null, Zone.HAND, source, game);
return true; return true;
} }
} }

View file

@ -5,7 +5,6 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.DiscardSourceCost; import mage.abilities.costs.common.DiscardSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.constants.Outcome; import mage.constants.Outcome;
@ -17,25 +16,29 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import java.util.UUID; import mage.MageObject;
import mage.constants.TimingRule; import mage.constants.TimingRule;
/** /**
* *
* 702.52. Transmute * 702.52. Transmute
* *
* 702.52a Transmute is an activated ability that functions only while the card with transmute is * 702.52a Transmute is an activated ability that functions only while the card
* in a players hand. Transmute [cost] means [Cost], Discard this card: Search your library for * with transmute is in a players hand. Transmute [cost] means [Cost],
* a card with the same converted mana cost as the discarded card, reveal that card, and put it into * Discard this card: Search your library for a card with the same converted
* your hand. Then shuffle your library. Play this ability only any time you could play a sorcery. * mana cost as the discarded card, reveal that card, and put it into your hand.
* Then shuffle your library. Play this ability only any time you could play a
* sorcery.
* *
* 702.52b Although the transmute ability is playable only if the card is in a players hand, it * 702.52b Although the transmute ability is playable only if the card is in a
* continues to exist while the object is in play and in all other zones. Therefore objects with * players hand, it continues to exist while the object is in play and in all
* transmute will be affected by effects that depend on objects having one or more activated abilities. * other zones. Therefore objects with transmute will be affected by effects
* that depend on objects having one or more activated abilities.
* *
* @author Loki * @author Loki
*/ */
public class TransmuteAbility extends SimpleActivatedAbility { public class TransmuteAbility extends SimpleActivatedAbility {
public TransmuteAbility(String manaCost) { public TransmuteAbility(String manaCost) {
super(Zone.HAND, new TransmuteEffect(), new ManaCostsImpl(manaCost)); super(Zone.HAND, new TransmuteEffect(), new ManaCostsImpl(manaCost));
this.setTiming(TimingRule.SORCERY); this.setTiming(TimingRule.SORCERY);
@ -60,6 +63,7 @@ public class TransmuteAbility extends SimpleActivatedAbility {
} }
class TransmuteEffect extends OneShotEffect { class TransmuteEffect extends OneShotEffect {
TransmuteEffect() { TransmuteEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
staticText = "Transmute"; staticText = "Transmute";
@ -71,27 +75,20 @@ class TransmuteEffect 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());
Card sourceCard = game.getCard(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) {
if (sourceCard != null && player != null) { FilterCard filter = new FilterCard("card with converted mana cost " + sourceObject.getManaCost().convertedManaCost());
FilterCard filter = new FilterCard("card with converted mana cost " + sourceCard.getManaCost().convertedManaCost()); filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, sourceObject.getManaCost().convertedManaCost()));
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, sourceCard.getManaCost().convertedManaCost()));
TargetCardInLibrary target = new TargetCardInLibrary(1, filter); TargetCardInLibrary target = new TargetCardInLibrary(1, filter);
if (player.searchLibrary(target, game)) { if (controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) { if (target.getTargets().size() > 0) {
Cards revealed = new CardsImpl(); Cards revealed = new CardsImpl(target.getTargets());
for (UUID cardId : target.getTargets()) { controller.revealCards(sourceObject.getIdName(), revealed, game);
Card card = player.getLibrary().remove(cardId, game); controller.moveCards(revealed, null, Zone.HAND, source, game);
if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
revealed.add(card);
}
}
player.revealCards("Search", revealed, game);
} }
} }
player.shuffleLibrary(game); controller.shuffleLibrary(game);
return true; return true;
} }

View file

@ -640,18 +640,17 @@ public interface Player extends MageItem, Copyable<Player> {
* @param fromZone if null, this info isn't postet * @param fromZone if null, this info isn't postet
* @return * @return
*/ */
boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone); boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game);
/** /**
* @param card * @param card
* @param sourceId * @param sourceId
* @param game * @param game
* @param withName show the card name in the log * @param withName show the card name in the log
* @param fromZone
* @return * @return
* *
*/ */
boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean withName); boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, boolean withName);
/** /**
* Uses card.moveToExile and posts a inform message about moving the card to * Uses card.moveToExile and posts a inform message about moving the card to
@ -662,7 +661,6 @@ public interface Player extends MageItem, Copyable<Player> {
* @param exileName name of exile zone (optional) * @param exileName name of exile zone (optional)
* @param sourceId * @param sourceId
* @param game * @param game
* @param fromZone if null, this info isn't postet
* @param withName * @param withName
* @return * @return
*/ */

View file

@ -2881,6 +2881,9 @@ public abstract class PlayerImpl implements Player, Serializable {
public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) { public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) {
ArrayList<Card> cardList = new ArrayList<>(); ArrayList<Card> cardList = new ArrayList<>();
for (UUID cardId : cards) { for (UUID cardId : cards) {
if (fromZone == null) {
fromZone = game.getState().getZone(cardId);
}
if (fromZone.equals(Zone.BATTLEFIELD)) { if (fromZone.equals(Zone.BATTLEFIELD)) {
Permanent permanent = game.getPermanent(cardId); Permanent permanent = game.getPermanent(cardId);
if (permanent != null) { if (permanent != null) {
@ -2925,6 +2928,7 @@ public abstract class PlayerImpl implements Player, Serializable {
case EXILED: case EXILED:
boolean result = false; boolean result = false;
for (Card card : cards) { for (Card card : cards) {
fromZone = game.getState().getZone(card.getId());
result |= moveCardToExileWithInfo(card, null, "", source == null ? null : source.getSourceId(), game, fromZone, withName); result |= moveCardToExileWithInfo(card, null, "", source == null ? null : source.getSourceId(), game, fromZone, withName);
} }
return result; return result;
@ -2933,18 +2937,21 @@ public abstract class PlayerImpl implements Player, Serializable {
case HAND: case HAND:
result = false; result = false;
for (Card card : cards) { for (Card card : cards) {
result |= moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, fromZone, withName); fromZone = game.getState().getZone(card.getId());
result |= moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, withName);
} }
return result; return result;
case BATTLEFIELD: case BATTLEFIELD:
result = false; result = false;
for (Card card : cards) { for (Card card : cards) {
fromZone = game.getState().getZone(card.getId());
result |= putOntoBattlefieldWithInfo(card, game, fromZone, source == null ? null : source.getSourceId(), false, !withName); result |= putOntoBattlefieldWithInfo(card, game, fromZone, source == null ? null : source.getSourceId(), false, !withName);
} }
return result; return result;
case LIBRARY: case LIBRARY:
result = false; result = false;
for (Card card : cards) { for (Card card : cards) {
fromZone = game.getState().getZone(card.getId());
result |= moveCardToLibraryWithInfo(card, source == null ? null : source.getSourceId(), game, fromZone, true, withName); result |= moveCardToLibraryWithInfo(card, source == null ? null : source.getSourceId(), game, fromZone, true, withName);
} }
return result; return result;
@ -2954,13 +2961,14 @@ public abstract class PlayerImpl implements Player, Serializable {
} }
@Override @Override
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) { public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game) {
return this.moveCardToHandWithInfo(card, sourceId, game, fromZone, true); return this.moveCardToHandWithInfo(card, sourceId, game, true);
} }
@Override @Override
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean withName) { public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, boolean withName) {
boolean result = false; boolean result = false;
Zone fromZone = game.getState().getZone(card.getId());
if (card.moveToZone(Zone.HAND, sourceId, game, false)) { if (card.moveToZone(Zone.HAND, sourceId, game, false)) {
if (card instanceof PermanentCard) { if (card instanceof PermanentCard) {
card = game.getCard(card.getId()); card = game.getCard(card.getId());
@ -3025,6 +3033,7 @@ public abstract class PlayerImpl implements Player, Serializable {
Card card = cards.get(targetObjectId, game); Card card = cards.get(targetObjectId, game);
cards.remove(targetObjectId); cards.remove(targetObjectId);
if (card != null) { if (card != null) {
fromZone = game.getState().getZone(card.getId());
result &= choosingPlayer.moveCardToGraveyardWithInfo(card, sourceId, game, fromZone); result &= choosingPlayer.moveCardToGraveyardWithInfo(card, sourceId, game, fromZone);
} }
target.clearChosen(); target.clearChosen();
@ -3045,6 +3054,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean moveCardToGraveyardWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) { public boolean moveCardToGraveyardWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
boolean result = false; boolean result = false;
// Zone fromZone = game.getState().getZone(card.getId());
if (card.moveToZone(Zone.GRAVEYARD, sourceId, game, fromZone != null ? fromZone.equals(Zone.BATTLEFIELD) : false)) { if (card.moveToZone(Zone.GRAVEYARD, sourceId, game, fromZone != null ? fromZone.equals(Zone.BATTLEFIELD) : false)) {
if (!game.isSimulation()) { if (!game.isSimulation()) {
if (card instanceof PermanentCard) { if (card instanceof PermanentCard) {
@ -3052,7 +3062,7 @@ public abstract class PlayerImpl implements Player, Serializable {
} }
StringBuilder sb = new StringBuilder(this.getLogName()) StringBuilder sb = new StringBuilder(this.getLogName())
.append(" puts ").append(card.getLogName()).append(" ") .append(" puts ").append(card.getLogName()).append(" ")
.append(fromZone != null ? new StringBuilder("from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ") : ""); .append(fromZone != null ? "from " + fromZone.toString().toLowerCase(Locale.ENGLISH) + " " : "");
if (card.getOwnerId().equals(getId())) { if (card.getOwnerId().equals(getId())) {
sb.append("into his or her graveyard"); sb.append("into his or her graveyard");
} else { } else {