From 6d87041d740a58295ce519db42c53e98bf508124 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Sat, 15 Apr 2023 20:34:46 -0400 Subject: [PATCH] [MOM] Implement Realmbreaker, the Invasion Tree --- .../cards/r/RealmbreakerTheInvasionTree.java | 156 ++++++++++++++++++ .../src/mage/sets/MarchOfTheMachine.java | 1 + 2 files changed, 157 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/r/RealmbreakerTheInvasionTree.java diff --git a/Mage.Sets/src/mage/cards/r/RealmbreakerTheInvasionTree.java b/Mage.Sets/src/mage/cards/r/RealmbreakerTheInvasionTree.java new file mode 100644 index 0000000000..3031bfaf4d --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RealmbreakerTheInvasionTree.java @@ -0,0 +1,156 @@ +package mage.cards.r; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.MillCardsTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterCard; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetCardInLibrary; +import mage.target.common.TargetOpponent; +import mage.target.targetpointer.FixedTarget; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class RealmbreakerTheInvasionTree extends CardImpl { + + private static final FilterCard filter = new FilterCard("Praetor cards"); + + static { + filter.add(SubType.PRAETOR.getPredicate()); + } + + public RealmbreakerTheInvasionTree(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); + + this.addSuperType(SuperType.LEGENDARY); + + // {2}, {T}: Target opponent mills three cards. Put a land card from their graveyard onto the battlefield tapped under your control. It gains "If this land would leave the battlefield, exile it instead of putting it anywhere else." + Ability ability = new SimpleActivatedAbility(new MillCardsTargetEffect(3), new GenericManaCost(2)); + ability.addCost(new TapSourceCost()); + ability.addEffect(new RealmbreakerTheInvasionTreeEffect()); + ability.addTarget(new TargetOpponent()); + + // {10}, {T}, Sacrifice Realmbreaker, the Invasion Tree: Search your library for any number of Praetor cards, put them onto the battlefield, then shuffle. + ability = new SimpleActivatedAbility(new SearchLibraryPutInPlayEffect( + new TargetCardInLibrary(0, Integer.MAX_VALUE, filter) + ), new GenericManaCost(10)); + ability.addCost(new TapSourceCost()); + ability.addCost(new SacrificeSourceCost()); + this.addAbility(ability); + } + + private RealmbreakerTheInvasionTree(final RealmbreakerTheInvasionTree card) { + super(card); + } + + @Override + public RealmbreakerTheInvasionTree copy() { + return new RealmbreakerTheInvasionTree(this); + } +} + +class RealmbreakerTheInvasionTreeEffect extends OneShotEffect { + + RealmbreakerTheInvasionTreeEffect() { + super(Outcome.Benefit); + staticText = "Put a land card from their graveyard onto the battlefield tapped under your control. " + + "It gains \"If this land would leave the battlefield, exile it instead of putting it anywhere else.\""; + } + + private RealmbreakerTheInvasionTreeEffect(final RealmbreakerTheInvasionTreeEffect effect) { + super(effect); + } + + @Override + public RealmbreakerTheInvasionTreeEffect copy() { + return new RealmbreakerTheInvasionTreeEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source)); + if (controller == null || opponent == null + || opponent.getGraveyard().count(StaticFilters.FILTER_CARD_LAND, game) < 1) { + return false; + } + TargetCard target = new TargetCardInGraveyard(StaticFilters.FILTER_CARD_LAND); + target.setNotTarget(true); + controller.choose(Outcome.PutLandInPlay, opponent.getGraveyard(), target, game); + Card card = game.getCard(target.getFirstTarget()); + if (card == null) { + return false; + } + controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); + Permanent permanent = game.getPermanent(card.getId()); + if (permanent == null) { + return false; + } + game.addEffect(new GainAbilityTargetEffect( + new SimpleStaticAbility(new RealmbreakerTheInvasionTreeReplacementEffect()), Duration.Custom + ).setTargetPointer(new FixedTarget(permanent, game)), source); + return true; + } +} + +class RealmbreakerTheInvasionTreeReplacementEffect extends ReplacementEffectImpl { + + RealmbreakerTheInvasionTreeReplacementEffect() { + super(Duration.WhileOnBattlefield, Outcome.Tap); + staticText = "If this land would leave the battlefield, exile it instead of putting it anywhere else"; + } + + private RealmbreakerTheInvasionTreeReplacementEffect(final RealmbreakerTheInvasionTreeReplacementEffect effect) { + super(effect); + } + + @Override + public RealmbreakerTheInvasionTreeReplacementEffect copy() { + return new RealmbreakerTheInvasionTreeReplacementEffect(this); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + ((ZoneChangeEvent) event).setToZone(Zone.EXILED); + return false; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ZONE_CHANGE; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return event.getTargetId().equals(source.getSourceId()) + && ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD + && ((ZoneChangeEvent) event).getToZone() != Zone.EXILED; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index dd45daca8b..6d9c15a339 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -259,6 +259,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Rankle and Torbran", 252, Rarity.RARE, mage.cards.r.RankleAndTorbran.class)); cards.add(new SetCardInfo("Ravenous Sailback", 202, Rarity.UNCOMMON, mage.cards.r.RavenousSailback.class)); cards.add(new SetCardInfo("Realmbreaker's Grasp", 33, Rarity.COMMON, mage.cards.r.RealmbreakersGrasp.class)); + cards.add(new SetCardInfo("Realmbreaker, the Invasion Tree", 263, Rarity.RARE, mage.cards.r.RealmbreakerTheInvasionTree.class)); cards.add(new SetCardInfo("Redcap Heelslasher", 161, Rarity.COMMON, mage.cards.r.RedcapHeelslasher.class)); cards.add(new SetCardInfo("Referee Squad", 327, Rarity.UNCOMMON, mage.cards.r.RefereeSquad.class)); cards.add(new SetCardInfo("Refraction Elemental", 146, Rarity.RARE, mage.cards.r.RefractionElemental.class));