From cd0c1231723a93b8354c53b033cd5a9749f1631a Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 31 May 2021 09:50:24 -0400 Subject: [PATCH] [MH2] Implemented Shattered Ego --- Mage.Sets/src/mage/cards/s/ShatteredEgo.java | 86 ++++++++++++++++++++ Mage.Sets/src/mage/sets/ModernHorizons2.java | 1 + 2 files changed, 87 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/ShatteredEgo.java diff --git a/Mage.Sets/src/mage/cards/s/ShatteredEgo.java b/Mage.Sets/src/mage/cards/s/ShatteredEgo.java new file mode 100644 index 0000000000..0a9df3f3a1 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/ShatteredEgo.java @@ -0,0 +1,86 @@ +package mage.cards.s; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.continuous.BoostEnchantedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +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.UUID; + +/** + * @author TheElk801 + */ +public final class ShatteredEgo extends CardImpl { + + public ShatteredEgo(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}"); + + this.subtype.add(SubType.AURA); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // Enchanted creature gets -3/-0. + this.addAbility(new SimpleStaticAbility(new BoostEnchantedEffect(-3, 0))); + + // {3}{U}{U}: Put enchanted creature into its owner's library third from the top. + this.addAbility(new SimpleActivatedAbility(new ShatteredEgoEffect(), new ManaCostsImpl<>("{3}{U}{U}"))); + } + + private ShatteredEgo(final ShatteredEgo card) { + super(card); + } + + @Override + public ShatteredEgo copy() { + return new ShatteredEgo(this); + } +} + +class ShatteredEgoEffect extends OneShotEffect { + + ShatteredEgoEffect() { + super(Outcome.Benefit); + staticText = "put enchanted creature into its owner's library third from the top"; + } + + private ShatteredEgoEffect(final ShatteredEgoEffect effect) { + super(effect); + } + + @Override + public ShatteredEgoEffect copy() { + return new ShatteredEgoEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Permanent aura = source.getSourcePermanentOrLKI(game); + if (player == null || aura == null) { + return false; + } + Permanent permanent = game.getPermanent(aura.getAttachedTo()); + return permanent != null && player.putCardOnTopXOfLibrary( + permanent, game, source, 3, true + ); + } +} diff --git a/Mage.Sets/src/mage/sets/ModernHorizons2.java b/Mage.Sets/src/mage/sets/ModernHorizons2.java index d826c0bd5f..c628fb36b4 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons2.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons2.java @@ -138,6 +138,7 @@ public final class ModernHorizons2 extends ExpansionSet { cards.add(new SetCardInfo("Seal of Cleansing", 264, Rarity.UNCOMMON, mage.cards.s.SealOfCleansing.class)); cards.add(new SetCardInfo("Seal of Removal", 269, Rarity.UNCOMMON, mage.cards.s.SealOfRemoval.class)); cards.add(new SetCardInfo("Shardless Agent", 321, Rarity.RARE, mage.cards.s.ShardlessAgent.class)); + cards.add(new SetCardInfo("Shattered Ego", 62, Rarity.COMMON, mage.cards.s.ShatteredEgo.class)); cards.add(new SetCardInfo("Silverbluff Bridge", 255, Rarity.COMMON, mage.cards.s.SilverbluffBridge.class)); cards.add(new SetCardInfo("Skirge Familiar", 276, Rarity.UNCOMMON, mage.cards.s.SkirgeFamiliar.class)); cards.add(new SetCardInfo("Skophos Reaver", 140, Rarity.COMMON, mage.cards.s.SkophosReaver.class));