diff --git a/Mage.Sets/src/mage/cards/r/RofellossGift.java b/Mage.Sets/src/mage/cards/r/RofellossGift.java new file mode 100644 index 00000000000..0b89988c673 --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RofellossGift.java @@ -0,0 +1,101 @@ +package mage.cards.r; + +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.cards.*; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.mageobject.ColorPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInHand; +import mage.target.common.TargetCardInYourGraveyard; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class RofellossGift extends CardImpl { + + public RofellossGift(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{G}"); + + // Reveal any number of green cards in your hand. Return an enchantment card from your graveyard to your hand for each card revealed this way. + this.getSpellAbility().addEffect(new RofellossGiftEffect()); + } + + public RofellossGift(final RofellossGift card) { + super(card); + } + + @Override + public RofellossGift copy() { + return new RofellossGift(this); + } +} + +class RofellossGiftEffect extends OneShotEffect { + + public static final FilterCard filter1 = new FilterCard("green cards in your hand"); + public static final FilterCard filter2 = new FilterCard("enchantment cards in your graveyard"); + + static { + filter1.add(new ColorPredicate(ObjectColor.GREEN)); + filter2.add(new CardTypePredicate(CardType.ENCHANTMENT)); + } + + public RofellossGiftEffect() { + super(Outcome.Benefit); + staticText = "Reveal any number of green cards in your hand. " + + "Return an enchantment card from your graveyard to your hand for each card revealed this way."; + } + + public RofellossGiftEffect(final RofellossGiftEffect effect) { + super(effect); + } + + @Override + public RofellossGiftEffect copy() { + return new RofellossGiftEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + TargetCardInHand targetCardInHand = new TargetCardInHand(0, Integer.MAX_VALUE, filter1); + if (!player.choose(outcome, player.getHand(), targetCardInHand, game)) { + return false; + } + Cards cards = new CardsImpl(); + for (UUID cardId : targetCardInHand.getTargets()) { + Card card = game.getCard(cardId); + if (card != null) { + cards.add(card); + } + } + player.revealCards(source, cards, game); + int enchantmentsToReturn = Math.min(player.getGraveyard().count(filter2, game), targetCardInHand.getTargets().size()); + TargetCardInYourGraveyard targetCardInYourGraveyard = new TargetCardInYourGraveyard(enchantmentsToReturn, filter2); + targetCardInYourGraveyard.setNotTarget(true); + if (!player.choose(outcome, targetCardInYourGraveyard, source.getSourceId(), game)) { + return false; + } + cards = new CardsImpl(); + for (UUID cardId : targetCardInYourGraveyard.getTargets()) { + Card card = game.getCard(cardId); + if (card != null) { + cards.add(card); + } + } + return player.moveCards(cards, Zone.HAND, source, game); + } +} diff --git a/Mage.Sets/src/mage/sets/UrzasDestiny.java b/Mage.Sets/src/mage/sets/UrzasDestiny.java index 0d1da153d20..17e0fd38ed1 100644 --- a/Mage.Sets/src/mage/sets/UrzasDestiny.java +++ b/Mage.Sets/src/mage/sets/UrzasDestiny.java @@ -120,6 +120,7 @@ public final class UrzasDestiny extends ExpansionSet { cards.add(new SetCardInfo("Repercussion", 95, Rarity.RARE, mage.cards.r.Repercussion.class)); cards.add(new SetCardInfo("Replenish", 15, Rarity.RARE, mage.cards.r.Replenish.class)); cards.add(new SetCardInfo("Rescue", 44, Rarity.COMMON, mage.cards.r.Rescue.class)); + cards.add(new SetCardInfo("Rofellos's Gift", 119, Rarity.COMMON, mage.cards.r.RofellossGift.class)); cards.add(new SetCardInfo("Rofellos, Llanowar Emissary", 118, Rarity.RARE, mage.cards.r.RofellosLlanowarEmissary.class)); cards.add(new SetCardInfo("Sanctimony", 16, Rarity.UNCOMMON, mage.cards.s.Sanctimony.class)); cards.add(new SetCardInfo("Scent of Brine", 45, Rarity.COMMON, mage.cards.s.ScentOfBrine.class));