diff --git a/Mage.Sets/src/mage/cards/b/BurningWish.java b/Mage.Sets/src/mage/cards/b/BurningWish.java index 33da702447a..2ca53ace478 100644 --- a/Mage.Sets/src/mage/cards/b/BurningWish.java +++ b/Mage.Sets/src/mage/cards/b/BurningWish.java @@ -29,8 +29,10 @@ package mage.cards.b; import java.util.Set; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -52,11 +54,11 @@ import mage.target.TargetCard; public class BurningWish extends CardImpl { public BurningWish(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{R}"); - + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{R}"); // You may choose a sorcery card you own from outside the game, reveal that card, and put it into your hand. Exile Burning Wish. this.getSpellAbility().addEffect(new BurningWishEffect()); + this.getSpellAbility().addEffect(ExileSpellEffect.getInstance()); } public BurningWish(final BurningWish card) { @@ -74,13 +76,14 @@ class BurningWishEffect extends OneShotEffect { private static final String choiceText = "Choose a sorcery card you own from outside the game, and put it into your hand"; private static final FilterCard filter = new FilterCard("sorcery card"); - static{ - filter.add(new CardTypePredicate(CardType.SORCERY)); + + static { + filter.add(new CardTypePredicate(CardType.SORCERY)); } public BurningWishEffect() { super(Outcome.Benefit); - this.staticText = "You may choose a sorcery card you own from outside the game, reveal that card, and put it into your hand. Exile Burning Wish"; + this.staticText = "You may choose a sorcery card you own from outside the game, reveal that card, and put it into your hand"; } public BurningWishEffect(final BurningWishEffect effect) { @@ -94,18 +97,19 @@ class BurningWishEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - while (player.chooseUse(Outcome.Benefit, choiceText, source, game)) { - Cards cards = player.getSideboard(); - if(cards.isEmpty()) { - game.informPlayer(player, "You have no cards outside the game."); + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (controller != null && sourceObject != null) { + while (controller.chooseUse(Outcome.Benefit, choiceText, source, game)) { + Cards cards = controller.getSideboard(); + if (cards.isEmpty()) { + game.informPlayer(controller, "You have no cards outside the game."); break; } Set filtered = cards.getCards(filter, game); if (filtered.isEmpty()) { - game.informPlayer(player, "You have no " + filter.getMessage() + " outside the game."); + game.informPlayer(controller, "You have no " + filter.getMessage() + " outside the game."); break; } @@ -115,25 +119,21 @@ class BurningWishEffect extends OneShotEffect { } TargetCard target = new TargetCard(Zone.OUTSIDE, filter); - if (player.choose(Outcome.Benefit, filteredCards, target, game)) { - Card card = player.getSideboard().get(target.getFirstTarget(), game); + if (controller.choose(Outcome.Benefit, filteredCards, target, game)) { + Card card = controller.getSideboard().get(target.getFirstTarget(), game); if (card != null) { card.moveToZone(Zone.HAND, source.getSourceId(), game, false); Cards revealCard = new CardsImpl(); revealCard.add(card); - player.revealCards("Burning Wish", revealCard, game); + controller.revealCards(sourceObject.getIdName(), revealCard, game); break; } } } - Card cardToExile = game.getCard(source.getSourceId()); - if(cardToExile != null) - { - cardToExile.moveToExile(null, "", source.getSourceId(), game); - } + return true; } - return true; + return false; } } diff --git a/Mage.Sets/src/mage/cards/c/CunningWish.java b/Mage.Sets/src/mage/cards/c/CunningWish.java index 3dfe79106b3..7813e92283f 100644 --- a/Mage.Sets/src/mage/cards/c/CunningWish.java +++ b/Mage.Sets/src/mage/cards/c/CunningWish.java @@ -29,8 +29,10 @@ package mage.cards.c; import java.util.Set; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -52,11 +54,11 @@ import mage.target.TargetCard; public class CunningWish extends CardImpl { public CunningWish(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}"); - + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}"); // You may choose an instant card you own from outside the game, reveal that card, and put it into your hand. Exile Cunning Wish. this.getSpellAbility().addEffect(new CunningWishEffect()); + this.getSpellAbility().addEffect(ExileSpellEffect.getInstance()); } public CunningWish(final CunningWish card) { @@ -74,13 +76,14 @@ class CunningWishEffect extends OneShotEffect { private static final String choiceText = "Choose an instant card you own from outside the game, and put it into your hand"; private static final FilterCard filter = new FilterCard("instant card"); - static{ - filter.add(new CardTypePredicate(CardType.INSTANT)); + + static { + filter.add(new CardTypePredicate(CardType.INSTANT)); } public CunningWishEffect() { super(Outcome.Benefit); - this.staticText = "You may choose an instant card you own from outside the game, reveal that card, and put it into your hand. Exile Cunning Wish"; + this.staticText = "You may choose an instant card you own from outside the game, reveal that card, and put it into your hand"; } public CunningWishEffect(final CunningWishEffect effect) { @@ -94,18 +97,19 @@ class CunningWishEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - while (player.chooseUse(Outcome.Benefit, choiceText, source, game)) { - Cards cards = player.getSideboard(); - if(cards.isEmpty()) { - game.informPlayer(player, "You have no cards outside the game."); + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (controller != null && sourceObject != null) { + while (controller.chooseUse(Outcome.Benefit, choiceText, source, game)) { + Cards cards = controller.getSideboard(); + if (cards.isEmpty()) { + game.informPlayer(controller, "You have no cards outside the game."); break; } Set filtered = cards.getCards(filter, game); if (filtered.isEmpty()) { - game.informPlayer(player, "You have no " + filter.getMessage() + " outside the game."); + game.informPlayer(controller, "You have no " + filter.getMessage() + " outside the game."); break; } @@ -115,25 +119,21 @@ class CunningWishEffect extends OneShotEffect { } TargetCard target = new TargetCard(Zone.OUTSIDE, filter); - if (player.choose(Outcome.Benefit, filteredCards, target, game)) { - Card card = player.getSideboard().get(target.getFirstTarget(), game); + if (controller.choose(Outcome.Benefit, filteredCards, target, game)) { + Card card = controller.getSideboard().get(target.getFirstTarget(), game); if (card != null) { card.moveToZone(Zone.HAND, source.getSourceId(), game, false); Cards revealCard = new CardsImpl(); revealCard.add(card); - player.revealCards("Cunning Wish", revealCard, game); + controller.revealCards(sourceObject.getIdName(), revealCard, game); break; } } } - Card cardToExile = game.getCard(source.getSourceId()); - if(cardToExile != null) - { - cardToExile.moveToExile(null, "", source.getSourceId(), game); - } + return true; } - return true; + return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/g/GlitteringWish.java b/Mage.Sets/src/mage/cards/g/GlitteringWish.java index 2c827ae824b..7cb4be71251 100644 --- a/Mage.Sets/src/mage/cards/g/GlitteringWish.java +++ b/Mage.Sets/src/mage/cards/g/GlitteringWish.java @@ -29,6 +29,7 @@ package mage.cards.g; import java.util.Set; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ExileSpellEffect; @@ -53,7 +54,7 @@ import mage.target.TargetCard; public class GlitteringWish extends CardImpl { public GlitteringWish(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{G}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{G}{W}"); // You may choose a multicolored card you own from outside the game, reveal that card, and put it into your hand. Exile Glittering Wish. this.getSpellAbility().addEffect(new GlitteringWishEffect()); @@ -97,7 +98,8 @@ class GlitteringWishEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { + MageObject sourceObject = source.getSourceObject(game); + if (controller != null && sourceObject != null) { while (controller.chooseUse(Outcome.Benefit, choiceText, source, game)) { Cards cards = controller.getSideboard(); if (cards.isEmpty()) { @@ -124,7 +126,7 @@ class GlitteringWishEffect extends OneShotEffect { card.moveToZone(Zone.HAND, source.getSourceId(), game, false); Cards revealCard = new CardsImpl(); revealCard.add(card); - controller.revealCards("Glittering Wish", revealCard, game); + controller.revealCards(sourceObject.getIdName(), revealCard, game); break; } } diff --git a/Mage.Sets/src/mage/cards/g/GoldenWish.java b/Mage.Sets/src/mage/cards/g/GoldenWish.java index 658642ae2a8..b283ae6283e 100644 --- a/Mage.Sets/src/mage/cards/g/GoldenWish.java +++ b/Mage.Sets/src/mage/cards/g/GoldenWish.java @@ -29,8 +29,10 @@ package mage.cards.g; import java.util.Set; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -53,11 +55,11 @@ import mage.target.TargetCard; public class GoldenWish extends CardImpl { public GoldenWish(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{W}{W}"); - + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{W}{W}"); // You may choose an artifact or enchantment card you own from outside the game, reveal that card, and put it into your hand. Exile Golden Wish. this.getSpellAbility().addEffect(new GoldenWishEffect()); + this.getSpellAbility().addEffect(ExileSpellEffect.getInstance()); } public GoldenWish(final GoldenWish card) { @@ -75,15 +77,16 @@ class GoldenWishEffect extends OneShotEffect { private static final String choiceText = "Choose an artifact or enchantment card you own from outside the game, and put it into your hand"; private static final FilterCard filter = new FilterCard("artifact or enchantment card"); - static{ - filter.add(Predicates.or( + + static { + filter.add(Predicates.or( new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.ENCHANTMENT))); } public GoldenWishEffect() { super(Outcome.Benefit); - this.staticText = "You may choose a artifact or enchantment card you own from outside the game, reveal that card, and put it into your hand. Exile Golden Wish"; + this.staticText = "You may choose a artifact or enchantment card you own from outside the game, reveal that card, and put it into your hand"; } public GoldenWishEffect(final GoldenWishEffect effect) { @@ -97,46 +100,38 @@ class GoldenWishEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - while (player.chooseUse(Outcome.Benefit, choiceText, source, game)) { - Cards cards = player.getSideboard(); - if(cards.isEmpty()) { - game.informPlayer(player, "You have no cards outside the game."); + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (controller != null && sourceObject != null) { + while (controller.chooseUse(Outcome.Benefit, choiceText, source, game)) { + Cards cards = controller.getSideboard(); + if (cards.isEmpty()) { + game.informPlayer(controller, "You have no cards outside the game."); break; } Set filtered = cards.getCards(filter, game); if (filtered.isEmpty()) { - game.informPlayer(player, "You have no " + filter.getMessage() + " outside the game."); + game.informPlayer(controller, "You have no " + filter.getMessage() + " outside the game."); break; } Cards filteredCards = new CardsImpl(); - for (Card card : filtered) { - filteredCards.add(card.getId()); - } + filteredCards.addAll(filtered); TargetCard target = new TargetCard(Zone.OUTSIDE, filter); - if (player.choose(Outcome.Benefit, filteredCards, target, game)) { - Card card = player.getSideboard().get(target.getFirstTarget(), game); + if (controller.choose(Outcome.Benefit, filteredCards, target, game)) { + Card card = controller.getSideboard().get(target.getFirstTarget(), game); if (card != null) { - card.moveToZone(Zone.HAND, source.getSourceId(), game, false); - Cards revealCard = new CardsImpl(); - revealCard.add(card); - player.revealCards("Golden Wish", revealCard, game); + controller.revealCards(sourceObject.getIdName(), new CardsImpl(card), game); break; } } } - Card cardToExile = game.getCard(source.getSourceId()); - if(cardToExile != null) - { - cardToExile.moveToExile(null, "", source.getSourceId(), game); - } + return true; } - return true; + return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/l/LivingWish.java b/Mage.Sets/src/mage/cards/l/LivingWish.java index fb416249254..96024485daf 100644 --- a/Mage.Sets/src/mage/cards/l/LivingWish.java +++ b/Mage.Sets/src/mage/cards/l/LivingWish.java @@ -29,8 +29,10 @@ package mage.cards.l; import java.util.Set; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileSpellEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -53,11 +55,11 @@ import mage.target.TargetCard; public class LivingWish extends CardImpl { public LivingWish(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{G}"); - + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{G}"); // You may choose a creature or land card you own from outside the game, reveal that card, and put it into your hand. Exile Living Wish. this.getSpellAbility().addEffect(new LivingWishEffect()); + this.getSpellAbility().addEffect(ExileSpellEffect.getInstance()); } public LivingWish(final LivingWish card) { @@ -75,15 +77,16 @@ class LivingWishEffect extends OneShotEffect { private static final String choiceText = "Choose a creature or land card you own from outside the game, and put it into your hand"; private static final FilterCard filter = new FilterCard("creature or land card"); - static{ - filter.add(Predicates.or( + + static { + filter.add(Predicates.or( new CardTypePredicate(CardType.CREATURE), new CardTypePredicate(CardType.LAND))); } public LivingWishEffect() { super(Outcome.Benefit); - this.staticText = "You may choose a creature or land card you own from outside the game, reveal that card, and put it into your hand. Exile Living Wish"; + this.staticText = "You may choose a creature or land card you own from outside the game, reveal that card, and put it into your hand"; } public LivingWishEffect(final LivingWishEffect effect) { @@ -97,18 +100,19 @@ class LivingWishEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - while (player.chooseUse(Outcome.Benefit, choiceText, source, game)) { - Cards cards = player.getSideboard(); - if(cards.isEmpty()) { - game.informPlayer(player, "You have no cards outside the game."); + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (controller != null && sourceObject != null) { + while (controller.chooseUse(Outcome.Benefit, choiceText, source, game)) { + Cards cards = controller.getSideboard(); + if (cards.isEmpty()) { + game.informPlayer(controller, "You have no cards outside the game."); break; } Set filtered = cards.getCards(filter, game); if (filtered.isEmpty()) { - game.informPlayer(player, "You have no " + filter.getMessage() + " outside the game."); + game.informPlayer(controller, "You have no " + filter.getMessage() + " outside the game."); break; } @@ -118,25 +122,21 @@ class LivingWishEffect extends OneShotEffect { } TargetCard target = new TargetCard(Zone.OUTSIDE, filter); - if (player.choose(Outcome.Benefit, filteredCards, target, game)) { - Card card = player.getSideboard().get(target.getFirstTarget(), game); + if (controller.choose(Outcome.Benefit, filteredCards, target, game)) { + Card card = controller.getSideboard().get(target.getFirstTarget(), game); if (card != null) { card.moveToZone(Zone.HAND, source.getSourceId(), game, false); Cards revealCard = new CardsImpl(); revealCard.add(card); - player.revealCards("Living Wish", revealCard, game); + controller.revealCards(sourceObject.getIdName(), revealCard, game); break; } } } - Card cardToExile = game.getCard(source.getSourceId()); - if(cardToExile != null) - { - cardToExile.moveToExile(null, "", source.getSourceId(), game); - } + return true; } - return true; + return false; } }