From 479f2d46e612f0b5abe329b100bfce2128e3b1ed Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Mon, 31 May 2021 18:44:01 -0500 Subject: [PATCH] [MH2] Implemented Graceful Restoration (#7869) --- .../src/mage/cards/g/GracefulRestoration.java | 99 +++++++++++++++++++ Mage.Sets/src/mage/sets/ModernHorizons2.java | 1 + 2 files changed, 100 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GracefulRestoration.java diff --git a/Mage.Sets/src/mage/cards/g/GracefulRestoration.java b/Mage.Sets/src/mage/cards/g/GracefulRestoration.java new file mode 100644 index 0000000000..565b523f0e --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GracefulRestoration.java @@ -0,0 +1,99 @@ +package mage.cards.g; + +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.InfoEffect; +import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.ComparisonType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.filter.common.FilterCreatureCard; +import mage.filter.predicate.mageobject.PowerPredicate; +import mage.game.Game; +import mage.game.events.EntersTheBattlefieldEvent; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.target.common.TargetCardInYourGraveyard; + +/** + * + * @author weirddan455 + */ +public final class GracefulRestoration extends CardImpl { + + private static final FilterCreatureCard filter = new FilterCreatureCard("creature cards with power 2 or less from your graveyard"); + + static { + filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, 3)); + } + + public GracefulRestoration(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{W}{B}"); + + // Choose one — + // • Return target creature card from your graveyard to the battlefield with an additional +1/+1 counter on it. + this.getSpellAbility().addEffect(new GracefulRestorationReplacementEffect()); + this.getSpellAbility().addEffect(new ReturnFromGraveyardToBattlefieldTargetEffect()); + this.getSpellAbility().addEffect(new InfoEffect("with an additional +1/+1 counter on it")); + this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD)); + + // • Return up to two target creature cards with power 2 or less from your graveyard to the battlefield. + Mode mode = new Mode(new ReturnFromGraveyardToBattlefieldTargetEffect()); + mode.addTarget(new TargetCardInYourGraveyard(0, 2, filter)); + this.getSpellAbility().addMode(mode); + } + + private GracefulRestoration(final GracefulRestoration card) { + super(card); + } + + @Override + public GracefulRestoration copy() { + return new GracefulRestoration(this); + } +} + +class GracefulRestorationReplacementEffect extends ReplacementEffectImpl { + + public GracefulRestorationReplacementEffect() { + super(Duration.EndOfStep, Outcome.BoostCreature); + } + + private GracefulRestorationReplacementEffect(final GracefulRestorationReplacementEffect effect) { + super(effect); + } + + @Override + public GracefulRestorationReplacementEffect copy() { + return new GracefulRestorationReplacementEffect(this); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return event.getTargetId().equals(getTargetPointer().getFirst(game, source)); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget(); + if (creature == null) { + return false; + } + creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects()); + discard(); + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/ModernHorizons2.java b/Mage.Sets/src/mage/sets/ModernHorizons2.java index ee59857fb3..b5e3039661 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons2.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons2.java @@ -89,6 +89,7 @@ public final class ModernHorizons2 extends ExpansionSet { cards.add(new SetCardInfo("Goblin Bombardment", 279, Rarity.RARE, mage.cards.g.GoblinBombardment.class)); cards.add(new SetCardInfo("Goldmire Bridge", 247, Rarity.COMMON, mage.cards.g.GoldmireBridge.class)); cards.add(new SetCardInfo("Gorilla Shaman", 280, Rarity.UNCOMMON, mage.cards.g.GorillaShaman.class)); + cards.add(new SetCardInfo("Graceful Restoration", 201, Rarity.UNCOMMON, mage.cards.g.GracefulRestoration.class)); cards.add(new SetCardInfo("Greed", 274, Rarity.UNCOMMON, mage.cards.g.Greed.class)); cards.add(new SetCardInfo("Grief", 87, Rarity.MYTHIC, mage.cards.g.Grief.class)); cards.add(new SetCardInfo("Harmonic Prodigy", 132, Rarity.RARE, mage.cards.h.HarmonicProdigy.class));