From e943d625773f52d9471773e4d3aef095ee014518 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Sun, 7 May 2023 18:38:03 -0400 Subject: [PATCH] [ONE] Implement Melira, the Living Cure (closes #10173) --- .../src/mage/cards/m/MeliraTheLivingCure.java | 143 ++++++++++++++++++ .../src/mage/sets/PhyrexiaAllWillBeOne.java | 1 + 2 files changed, 144 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MeliraTheLivingCure.java diff --git a/Mage.Sets/src/mage/cards/m/MeliraTheLivingCure.java b/Mage.Sets/src/mage/cards/m/MeliraTheLivingCure.java new file mode 100644 index 0000000000..2e165df63d --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MeliraTheLivingCure.java @@ -0,0 +1,143 @@ +package mage.cards.m; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.common.delayed.WhenTargetDiesDelayedTriggeredAbility; +import mage.abilities.costs.common.ExileSourceCost; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; +import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.AnotherPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author huangn, TheElk801 + */ +public final class MeliraTheLivingCure extends CardImpl { + + private static final FilterPermanent filter = new FilterPermanent("another target artifact or creature"); + + static { + filter.add(AnotherPredicate.instance); + filter.add(Predicates.or( + CardType.ARTIFACT.getPredicate(), + CardType.CREATURE.getPredicate() + )); + } + + public MeliraTheLivingCure(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}{W}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.SCOUT); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // If you would get one or more poison counters, instead you get one poison counter and you can't get additional poison counters this turn. + this.addAbility(new SimpleStaticAbility(new MeliraTheLivingCurePreventionEffect())); + + // Exile Melira, the Living Cure: Choose another target creature or artifact. When it's put into a graveyard this turn, return that card to the battlefield under its owner's control. + Ability ability = new SimpleActivatedAbility(new CreateDelayedTriggeredAbilityEffect( + new WhenTargetDiesDelayedTriggeredAbility( + new ReturnFromGraveyardToBattlefieldTargetEffect() + .setText("return that card to the battlefield under its owner's control"), + SetTargetPointer.CARD + ).setTriggerPhrase("Choose another target creature or artifact. " + + "When it's put into a graveyard this turn, ") + ), new ExileSourceCost()); + ability.addTarget(new TargetPermanent(filter)); + this.addAbility(ability); + } + + private MeliraTheLivingCure(final MeliraTheLivingCure card) { + super(card); + } + + @Override + public MeliraTheLivingCure copy() { + return new MeliraTheLivingCure(this); + } +} + +class MeliraTheLivingCureReplacmentEffect extends ReplacementEffectImpl { + + MeliraTheLivingCureReplacmentEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "if you would get one or more poison counters, instead you get " + + "one poison counter and you can't get additional poison counters this turn"; + } + + private MeliraTheLivingCureReplacmentEffect(final MeliraTheLivingCureReplacmentEffect effect) { + super(effect); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + event.setAmount(1); + game.addEffect(new MeliraTheLivingCurePreventionEffect(), source); + return false; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ADD_COUNTERS; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return source.isControlledBy(event.getTargetId()) + && CounterType.POISON.getName().equals(event.getData()) + && event.getAmount() > 0; + } + + @Override + public MeliraTheLivingCureReplacmentEffect copy() { + return new MeliraTheLivingCureReplacmentEffect(this); + } +} + +class MeliraTheLivingCurePreventionEffect extends ReplacementEffectImpl { + + MeliraTheLivingCurePreventionEffect() { + super(Duration.EndOfTurn, Outcome.Benefit); + } + + private MeliraTheLivingCurePreventionEffect(final MeliraTheLivingCurePreventionEffect effect) { + super(effect); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + return true; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ADD_COUNTERS; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return source.isControlledBy(event.getTargetId()) + && CounterType.POISON.getName().equals(event.getData()) + && event.getAmount() > 0; + } + + @Override + public MeliraTheLivingCurePreventionEffect copy() { + return new MeliraTheLivingCurePreventionEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java index 282976a7d7..6fe85cc6af 100644 --- a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java +++ b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java @@ -168,6 +168,7 @@ public final class PhyrexiaAllWillBeOne extends ExpansionSet { cards.add(new SetCardInfo("Maze's Mantle", 174, Rarity.COMMON, mage.cards.m.MazesMantle.class)); cards.add(new SetCardInfo("Meldweb Curator", 59, Rarity.COMMON, mage.cards.m.MeldwebCurator.class)); cards.add(new SetCardInfo("Meldweb Strider", 60, Rarity.COMMON, mage.cards.m.MeldwebStrider.class)); + cards.add(new SetCardInfo("Melira, the Living Cure", 209, Rarity.RARE, mage.cards.m.MeliraTheLivingCure.class)); cards.add(new SetCardInfo("Mercurial Spelldancer", 61, Rarity.RARE, mage.cards.m.MercurialSpelldancer.class)); cards.add(new SetCardInfo("Mesmerizing Dose", 62, Rarity.COMMON, mage.cards.m.MesmerizingDose.class)); cards.add(new SetCardInfo("Migloz, Maze Crusher", 210, Rarity.RARE, mage.cards.m.MiglozMazeCrusher.class));