From c17d01bce4101083b27bc0812ac96e64f3486435 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Wed, 2 Feb 2022 09:45:18 -0600 Subject: [PATCH] [NEO] Implemented Anchor to Reality --- .../src/mage/cards/a/AnchorToReality.java | 110 ++++++++++++++++++ .../src/mage/sets/KamigawaNeonDynasty.java | 1 + 2 files changed, 111 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/a/AnchorToReality.java diff --git a/Mage.Sets/src/mage/cards/a/AnchorToReality.java b/Mage.Sets/src/mage/cards/a/AnchorToReality.java new file mode 100644 index 0000000000..13d6880dec --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AnchorToReality.java @@ -0,0 +1,110 @@ +package mage.cards.a; + +import java.util.List; +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.Predicates; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCardInLibrary; + +/** + * + * @author weirddan455 + */ +public final class AnchorToReality extends CardImpl { + + private static final FilterControlledPermanent filter = new FilterControlledPermanent("an artifact or creature"); + + static { + filter.add(Predicates.or(CardType.ARTIFACT.getPredicate(), CardType.CREATURE.getPredicate())); + } + + public AnchorToReality(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{U}{U}"); + + // As an additional cost to cast this spell, sacrifice an artifact or creature. + this.getSpellAbility().addCost(new SacrificeTargetCost(filter)); + + // Search your library for an Equipment or Vehicle card, put it onto the battlefield, then shuffle. If its mana value is less than the sacrificed permanent's mana value, scry 2. + this.getSpellAbility().addEffect(new AnchorToRealityEffect()); + } + + private AnchorToReality(final AnchorToReality card) { + super(card); + } + + @Override + public AnchorToReality copy() { + return new AnchorToReality(this); + } +} + +class AnchorToRealityEffect extends OneShotEffect { + + private static final FilterCard filter = new FilterCard("an Equipment or Vehicle card"); + + static { + filter.add(Predicates.or(SubType.EQUIPMENT.getPredicate(), SubType.VEHICLE.getPredicate())); + } + + public AnchorToRealityEffect() { + super(Outcome.PutCardInPlay); + this.staticText = "Search your library for an Equipment or Vehicle card, put it onto the battlefield, then shuffle. If its mana value is less than the sacrificed permanent's mana value, scry 2"; + } + + private AnchorToRealityEffect(final AnchorToRealityEffect effect) { + super(effect); + } + + @Override + public AnchorToRealityEffect copy() { + return new AnchorToRealityEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + TargetCardInLibrary target = new TargetCardInLibrary(filter); + controller.searchLibrary(target, source, game); + Card card = game.getCard(target.getFirstTarget()); + if (card == null) { + controller.shuffleLibrary(source, game); + return true; + } + int searchedManaValue = card.getManaValue(); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); + controller.shuffleLibrary(source, game); + int sacrificedManaValue = 0; + for (Cost cost : source.getCosts()) { + if (cost instanceof SacrificeTargetCost) { + List sacrificedPermanents = ((SacrificeTargetCost) cost).getPermanents(); + if (sacrificedPermanents.size() > 0) { + sacrificedManaValue = sacrificedPermanents.get(0).getManaValue(); + break; + } + } + } + if (searchedManaValue < sacrificedManaValue) { + controller.scry(2, source, game); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java b/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java index 21a9131621..f19a932159 100644 --- a/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java +++ b/Mage.Sets/src/mage/sets/KamigawaNeonDynasty.java @@ -29,6 +29,7 @@ public final class KamigawaNeonDynasty extends ExpansionSet { cards.add(new SetCardInfo("Akki Ember-Keeper", 130, Rarity.COMMON, mage.cards.a.AkkiEmberKeeper.class)); cards.add(new SetCardInfo("Akki War Paint", 132, Rarity.COMMON, mage.cards.a.AkkiWarPaint.class)); cards.add(new SetCardInfo("Ancestral Katana", 1, Rarity.COMMON, mage.cards.a.AncestralKatana.class)); + cards.add(new SetCardInfo("Anchor to Reality", 45, Rarity.UNCOMMON, mage.cards.a.AnchorToReality.class)); cards.add(new SetCardInfo("Ao, the Dawn Sky", 2, Rarity.MYTHIC, mage.cards.a.AoTheDawnSky.class)); cards.add(new SetCardInfo("Armguard Familiar", 46, Rarity.COMMON, mage.cards.a.ArmguardFamiliar.class)); cards.add(new SetCardInfo("Asari Captain", 215, Rarity.UNCOMMON, mage.cards.a.AsariCaptain.class));