diff --git a/Mage.Sets/src/mage/cards/d/DanceOfTheManse.java b/Mage.Sets/src/mage/cards/d/DanceOfTheManse.java new file mode 100644 index 0000000000..b46a38d00c --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DanceOfTheManse.java @@ -0,0 +1,122 @@ +package mage.cards.d; + +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.AddCardTypeTargetEffect; +import mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.*; +import mage.filter.FilterCard; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.Target; +import mage.target.common.TargetCardInYourGraveyard; +import mage.target.targetadjustment.TargetAdjuster; +import mage.target.targetpointer.FixedTarget; + +import java.util.Collection; +import java.util.Objects; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class DanceOfTheManse extends CardImpl { + + public DanceOfTheManse(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{W}{U}"); + + // Return up to X target artifact and/or non-Aura enchantment cards each with converted mana cost X or less from your graveyard to the battlefield. If X is 6 or more, those permanents are 4/4 creatures in addition to their other types. + this.getSpellAbility().addEffect(new DanceOfTheManseEffect()); + this.getSpellAbility().setTargetAdjuster(DanceOfTheManseAdjuster.instance); + } + + private DanceOfTheManse(final DanceOfTheManse card) { + super(card); + } + + @Override + public DanceOfTheManse copy() { + return new DanceOfTheManse(this); + } +} + +enum DanceOfTheManseAdjuster implements TargetAdjuster { + instance; + + @Override + public void adjustTargets(Ability ability, Game game) { + int xValue = ability.getManaCostsToPay().getX(); + FilterCard filter = new FilterCard("artifact and/or non-Aura enchantment cards " + + "each with converted mana cost " + xValue + " or less from your graveyard"); + filter.add(Predicates.or( + new CardTypePredicate(CardType.ARTIFACT), + Predicates.and( + new CardTypePredicate(CardType.ENCHANTMENT), + Predicates.not(new SubtypePredicate(SubType.AURA)) + ) + )); + filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1)); + ability.getTargets().clear(); + ability.addTarget(new TargetCardInYourGraveyard(0, xValue, filter)); + } +} + +class DanceOfTheManseEffect extends OneShotEffect { + + DanceOfTheManseEffect() { + super(Outcome.Benefit); + staticText = "Return up to X target artifact and/or non-Aura enchantment cards " + + "each with converted mana cost X or less from your graveyard to the battlefield. " + + "If X is 6 or more, those permanents are 4/4 creatures in addition to their other types."; + } + + private DanceOfTheManseEffect(final DanceOfTheManseEffect effect) { + super(effect); + } + + @Override + public DanceOfTheManseEffect copy() { + return new DanceOfTheManseEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Cards cards = new CardsImpl(source + .getTargets() + .stream() + .map(Target::getTargets) + .flatMap(Collection::stream) + .map(game::getCard) + .collect(Collectors.toSet())); + player.moveCards(cards, Zone.BATTLEFIELD, source, game); + if (source.getManaCostsToPay().getX() < 6) { + return true; + } + cards.stream() + .map(game::getPermanent) + .filter(Objects::nonNull) + .forEach(permanent -> { + ContinuousEffect effect = new AddCardTypeTargetEffect(Duration.EndOfGame, CardType.CREATURE); + effect.setTargetPointer(new FixedTarget(permanent, game)); + game.addEffect(effect, source); + effect = new SetPowerToughnessTargetEffect(4, 4, Duration.EndOfGame); + effect.setTargetPointer(new FixedTarget(permanent, game)); + game.addEffect(effect, source); + }); + return true; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java index 26abff6992..f5c09c4a0c 100644 --- a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java +++ b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java @@ -56,6 +56,7 @@ public final class ThroneOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Corridor Monitor", 41, Rarity.COMMON, mage.cards.c.CorridorMonitor.class)); cards.add(new SetCardInfo("Crystal Slipper", 119, Rarity.COMMON, mage.cards.c.CrystalSlipper.class)); cards.add(new SetCardInfo("Curious Pair", 150, Rarity.COMMON, mage.cards.c.CuriousPair.class)); + cards.add(new SetCardInfo("Dance of the Manse", 186, Rarity.RARE, mage.cards.d.DanceOfTheManse.class)); cards.add(new SetCardInfo("Deafening Silence", 10, Rarity.UNCOMMON, mage.cards.d.DeafeningSilence.class)); cards.add(new SetCardInfo("Doom Foretold", 187, Rarity.RARE, mage.cards.d.DoomForetold.class)); cards.add(new SetCardInfo("Edgewall Innkeeper", 151, Rarity.UNCOMMON, mage.cards.e.EdgewallInnkeeper.class));