From 5c0084699bfcada6ff1e7025cc8b037d80f7be35 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 3 Jan 2019 21:22:42 -0500 Subject: [PATCH] Implemented Prime Speaker Vannifar --- Mage.Sets/src/mage/cards/b/BirthingPod.java | 46 ++++---- .../mage/cards/p/PrimeSpeakerVannifar.java | 107 ++++++++++++++++++ .../src/mage/sets/RavnicaAllegiance.java | 1 + 3 files changed, 134 insertions(+), 20 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/p/PrimeSpeakerVannifar.java diff --git a/Mage.Sets/src/mage/cards/b/BirthingPod.java b/Mage.Sets/src/mage/cards/b/BirthingPod.java index 2242e3886d6..179040611b0 100644 --- a/Mage.Sets/src/mage/cards/b/BirthingPod.java +++ b/Mage.Sets/src/mage/cards/b/BirthingPod.java @@ -1,7 +1,6 @@ package mage.cards.b; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.ActivateAsSorceryActivatedAbility; import mage.abilities.costs.Cost; @@ -17,7 +16,7 @@ import mage.constants.ComparisonType; import mage.constants.Outcome; import mage.constants.Zone; import mage.filter.FilterCard; -import static mage.filter.StaticFilters.FILTER_CONTROLLED_CREATURE_SHORT_TEXT; +import mage.filter.StaticFilters; import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; import mage.game.Game; @@ -26,6 +25,8 @@ import mage.players.Player; import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetControlledCreaturePermanent; +import java.util.UUID; + /** * @author Loki */ @@ -36,9 +37,13 @@ public final class BirthingPod extends CardImpl { // {1}{G/P}, {tap}, Sacrifice a creature: Search your library for a creature card with converted mana cost equal to 1 plus the sacrificed creature's converted mana cost, // put that card onto the battlefield, then shuffle your library. Activate this ability only any time you could cast a sorcery. - Ability ability = new ActivateAsSorceryActivatedAbility(Zone.BATTLEFIELD, new BirthingPodEffect(), new ManaCostsImpl("{1}{G/P}")); + Ability ability = new ActivateAsSorceryActivatedAbility( + Zone.BATTLEFIELD, new BirthingPodEffect(), new ManaCostsImpl("{1}{G/P}") + ); ability.addCost(new TapSourceCost()); - ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT))); + ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent( + StaticFilters.FILTER_CONTROLLED_CREATURE_SHORT_TEXT + ))); this.addAbility(ability); } @@ -56,11 +61,12 @@ class BirthingPodEffect extends OneShotEffect { BirthingPodEffect() { super(Outcome.Benefit); - staticText = "Search your library for a creature card with converted mana cost equal to 1 plus the sacrificed creature's converted mana cost, put that card " - + "onto the battlefield, then shuffle your library"; + staticText = "Search your library for a creature card with converted mana cost equal to 1 " + + "plus the sacrificed creature's converted mana cost, put that card " + + "onto the battlefield, then shuffle your library"; } - BirthingPodEffect(final BirthingPodEffect effect) { + private BirthingPodEffect(final BirthingPodEffect effect) { super(effect); } @@ -77,20 +83,20 @@ class BirthingPodEffect extends OneShotEffect { } } Player controller = game.getPlayer(source.getControllerId()); - if (sacrificedPermanent != null && controller != null) { - int newConvertedCost = sacrificedPermanent.getConvertedManaCost() + 1; - FilterCard filter = new FilterCard("creature card with converted mana cost " + newConvertedCost); - filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, newConvertedCost)); - filter.add(new CardTypePredicate(CardType.CREATURE)); - TargetCardInLibrary target = new TargetCardInLibrary(filter); - if (controller.searchLibrary(target, game)) { - Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); - controller.moveCards(card, Zone.BATTLEFIELD, source, game); - } - controller.shuffleLibrary(source, game); - return true; + if (sacrificedPermanent == null || controller == null) { + return false; } - return false; + int newConvertedCost = sacrificedPermanent.getConvertedManaCost() + 1; + FilterCard filter = new FilterCard("creature card with converted mana cost " + newConvertedCost); + filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, newConvertedCost)); + filter.add(new CardTypePredicate(CardType.CREATURE)); + TargetCardInLibrary target = new TargetCardInLibrary(filter); + if (controller.searchLibrary(target, game)) { + Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); + } + controller.shuffleLibrary(source, game); + return true; } @Override diff --git a/Mage.Sets/src/mage/cards/p/PrimeSpeakerVannifar.java b/Mage.Sets/src/mage/cards/p/PrimeSpeakerVannifar.java new file mode 100644 index 00000000000..3554ba25ade --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PrimeSpeakerVannifar.java @@ -0,0 +1,107 @@ +package mage.cards.p; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.ActivateAsSorceryActivatedAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.OneShotEffect; +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.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCardInLibrary; +import mage.target.common.TargetControlledCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 and Loki + */ +public final class PrimeSpeakerVannifar extends CardImpl { + + public PrimeSpeakerVannifar(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{U}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.ELF); + this.subtype.add(SubType.OOZE); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(2); + this.toughness = new MageInt(4); + + // {T}, Sacrifice another creature: Search your library for a creature card with converted mana cost equal to 1 plus the sacrificed creature's converted mana cost, put that card onto the battlefield, then shuffle your library. Activate this ability only any time you could cast a sorcery. + Ability ability = new ActivateAsSorceryActivatedAbility( + Zone.BATTLEFIELD, new PrimeSpeakerVannifarEffect(), new TapSourceCost() + ); + ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent( + StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE + ))); + this.addAbility(ability); + } + + private PrimeSpeakerVannifar(final PrimeSpeakerVannifar card) { + super(card); + } + + @Override + public PrimeSpeakerVannifar copy() { + return new PrimeSpeakerVannifar(this); + } +} + +class PrimeSpeakerVannifarEffect extends OneShotEffect { + + PrimeSpeakerVannifarEffect() { + super(Outcome.Benefit); + staticText = "Search your library for a creature card with converted mana cost equal to 1 " + + "plus the sacrificed creature's converted mana cost, put that card " + + "onto the battlefield, then shuffle your library"; + } + + private PrimeSpeakerVannifarEffect(final PrimeSpeakerVannifarEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent sacrificedPermanent = null; + for (Cost cost : source.getCosts()) { + if (cost instanceof SacrificeTargetCost) { + SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost; + if (!sacrificeCost.getPermanents().isEmpty()) { + sacrificedPermanent = sacrificeCost.getPermanents().get(0); + } + break; + } + } + Player controller = game.getPlayer(source.getControllerId()); + if (sacrificedPermanent == null || controller == null) { + return false; + } + int newConvertedCost = sacrificedPermanent.getConvertedManaCost() + 1; + FilterCard filter = new FilterCard("creature card with converted mana cost " + newConvertedCost); + filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, newConvertedCost)); + filter.add(new CardTypePredicate(CardType.CREATURE)); + TargetCardInLibrary target = new TargetCardInLibrary(filter); + if (controller.searchLibrary(target, game)) { + Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); + } + controller.shuffleLibrary(source, game); + return true; + } + + @Override + public PrimeSpeakerVannifarEffect copy() { + return new PrimeSpeakerVannifarEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/RavnicaAllegiance.java b/Mage.Sets/src/mage/sets/RavnicaAllegiance.java index 6f170cbf430..0159ef9a49e 100644 --- a/Mage.Sets/src/mage/sets/RavnicaAllegiance.java +++ b/Mage.Sets/src/mage/sets/RavnicaAllegiance.java @@ -72,6 +72,7 @@ public final class RavnicaAllegiance extends ExpansionSet { cards.add(new SetCardInfo("Pestilent Spirit", 81, Rarity.RARE, mage.cards.p.PestilentSpirit.class)); cards.add(new SetCardInfo("Pitiless Pontiff", 194, Rarity.UNCOMMON, mage.cards.p.PitilessPontiff.class)); cards.add(new SetCardInfo("Precognitive Perception", 45, Rarity.RARE, mage.cards.p.PrecognitivePerception.class)); + cards.add(new SetCardInfo("Prime Speaker Vannifar", 195, Rarity.MYTHIC, mage.cards.p.PrimeSpeakerVannifar.class)); cards.add(new SetCardInfo("Rafter Demon", 196, Rarity.COMMON, mage.cards.r.RafterDemon.class)); cards.add(new SetCardInfo("Rakdos Firewheeler", 197, Rarity.UNCOMMON, mage.cards.r.RakdosFirewheeler.class)); cards.add(new SetCardInfo("Rakdos Guildgate", 255, Rarity.COMMON, mage.cards.r.RakdosGuildgate.class, NON_FULL_USE_VARIOUS));