diff --git a/Mage.Sets/src/mage/cards/b/BroughtBack.java b/Mage.Sets/src/mage/cards/b/BroughtBack.java new file mode 100644 index 0000000000..e50015d587 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BroughtBack.java @@ -0,0 +1,64 @@ +package mage.cards.b; + +import mage.MageObjectReference; +import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.filter.FilterCard; +import mage.filter.common.FilterPermanentCard; +import mage.filter.predicate.Predicate; +import mage.game.Game; +import mage.target.common.TargetCardInYourGraveyard; +import mage.watchers.common.CardsPutIntoGraveyardWatcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class BroughtBack extends CardImpl { + + private static final FilterCard filter = new FilterPermanentCard( + "permanent cards in your graveyard that were put there from the battlefield this turn" + ); + + static { + filter.add(BroughtBackPredicate.instance); + } + + public BroughtBack(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{W}{W}"); + + // Choose up to two target permanent cards in your graveyard that were put there from the battlefield this turn. Return them to the battlefield tapped. + this.getSpellAbility().addEffect( + new ReturnFromGraveyardToBattlefieldTargetEffect() + .setText("Choose up to two target permanent cards in your graveyard " + + "that were put there from the battlefield this turn. " + + "Return them to the battlefield tapped.") + ); + this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 2, filter)); + this.getSpellAbility().addWatcher(new CardsPutIntoGraveyardWatcher()); + } + + private BroughtBack(final BroughtBack card) { + super(card); + } + + @Override + public BroughtBack copy() { + return new BroughtBack(this); + } +} + +enum BroughtBackPredicate implements Predicate { + instance; + + @Override + public boolean apply(Card input, Game game) { + CardsPutIntoGraveyardWatcher watcher = game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class); + return watcher != null + && watcher.getCardsPutToGraveyardFromBattlefield().contains(new MageObjectReference(input, game)); + } +} diff --git a/Mage.Sets/src/mage/sets/CoreSet2020.java b/Mage.Sets/src/mage/sets/CoreSet2020.java index 3c0b20dd7f..c4543434fe 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2020.java +++ b/Mage.Sets/src/mage/sets/CoreSet2020.java @@ -63,6 +63,7 @@ public final class CoreSet2020 extends ExpansionSet { cards.add(new SetCardInfo("Blossoming Sands", 243, Rarity.COMMON, mage.cards.b.BlossomingSands.class)); cards.add(new SetCardInfo("Bone Splinters", 92, Rarity.COMMON, mage.cards.b.BoneSplinters.class)); cards.add(new SetCardInfo("Boneclad Necromancer", 93, Rarity.COMMON, mage.cards.b.BonecladNecromancer.class)); + cards.add(new SetCardInfo("Brought Back", 9, Rarity.RARE, mage.cards.b.BroughtBack.class)); cards.add(new SetCardInfo("Captivating Gyre", 51, Rarity.UNCOMMON, mage.cards.c.CaptivatingGyre.class)); cards.add(new SetCardInfo("Cavalier of Dawn", 10, Rarity.MYTHIC, mage.cards.c.CavalierOfDawn.class)); cards.add(new SetCardInfo("Cavalier of Flame", 125, Rarity.MYTHIC, mage.cards.c.CavalierOfFlame.class));