diff --git a/Mage.Sets/src/mage/cards/d/DisturbingConversion.java b/Mage.Sets/src/mage/cards/d/DisturbingConversion.java new file mode 100644 index 0000000000..44661e2057 --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DisturbingConversion.java @@ -0,0 +1,102 @@ +package mage.cards.d; + +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.StaticValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.MillCardsEachPlayerEffect; +import mage.abilities.effects.common.continuous.BoostEnchantedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.abilities.keyword.FlashAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.TargetController; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.HashSet; +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class DisturbingConversion extends CardImpl { + + public DisturbingConversion(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}"); + + this.subtype.add(SubType.AURA); + + // Flash + this.addAbility(FlashAbility.getInstance()); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + this.addAbility(new EnchantAbility(auraTarget)); + + // When Disturbing Conversion enters the battlefield, each player mills two cards. + this.addAbility(new EntersBattlefieldTriggeredAbility( + new MillCardsEachPlayerEffect(2, TargetController.EACH_PLAYER) + )); + + // Enchanted creature gets -X/-0, where X is the number of cards in its controller's graveyard. + this.addAbility(new SimpleStaticAbility(new BoostEnchantedEffect( + DisturbingConversionValue.instance, StaticValue.get(0) + ))); + } + + private DisturbingConversion(final DisturbingConversion card) { + super(card); + } + + @Override + public DisturbingConversion copy() { + return new DisturbingConversion(this); + } +} + +enum DisturbingConversionValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + return -Optional + .ofNullable(sourceAbility.getSourcePermanentOrLKI(game)) + .filter(Objects::nonNull) + .map(Permanent::getAttachedTo) + .map(game::getControllerId) + .map(game::getPlayer) + .filter(Objects::nonNull) + .map(Player::getGraveyard) + .map(HashSet::size) + .orElse(0); + } + + @Override + public DisturbingConversionValue copy() { + return this; + } + + @Override + public String getMessage() { + return "the number of cards in its controller's graveyard"; + } + + @Override + public String toString() { + return "-X"; + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index 61b5dfed05..965cbc01a7 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -70,6 +70,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Deadly Derision", 99, Rarity.COMMON, mage.cards.d.DeadlyDerision.class)); cards.add(new SetCardInfo("Deeproot Wayfinder", 184, Rarity.RARE, mage.cards.d.DeeprootWayfinder.class)); cards.add(new SetCardInfo("Dismal Backwater", 269, Rarity.COMMON, mage.cards.d.DismalBackwater.class)); + cards.add(new SetCardInfo("Disturbing Conversion", 54, Rarity.COMMON, mage.cards.d.DisturbingConversion.class)); cards.add(new SetCardInfo("Dreg Recycler", 100, Rarity.COMMON, mage.cards.d.DregRecycler.class)); cards.add(new SetCardInfo("Dusk Legion Duelist", 11, Rarity.RARE, mage.cards.d.DuskLegionDuelist.class)); cards.add(new SetCardInfo("Elspeth's Smite", 13, Rarity.UNCOMMON, mage.cards.e.ElspethsSmite.class));