From eea6a9408d45eef71ff651caf717bc7d57045af5 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Sun, 27 Dec 2020 03:28:25 -0600 Subject: [PATCH] [KHM] Implemented Pyre of Heroes --- Mage.Sets/src/mage/cards/p/PyreOfHeroes.java | 127 +++++++++++++++++++ Mage.Sets/src/mage/sets/Kaldheim.java | 1 + 2 files changed, 128 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/p/PyreOfHeroes.java diff --git a/Mage.Sets/src/mage/cards/p/PyreOfHeroes.java b/Mage.Sets/src/mage/cards/p/PyreOfHeroes.java new file mode 100644 index 00000000000..1005785eca0 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PyreOfHeroes.java @@ -0,0 +1,127 @@ +package mage.cards.p; + +import java.util.UUID; + +import mage.MageObject; +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.costs.mana.GenericManaCost; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.ComparisonType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.StaticFilters; +import mage.filter.predicate.Predicate; +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; + +/** + * + * @author weirddan455 + */ +public final class PyreOfHeroes extends CardImpl { + + public PyreOfHeroes(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); + + // {2}, {T}, Sacrifice a creature: Search your library for a creature card that shares a creature type with the sacrificed creature and has converted mana cost equal to 1 plus that 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 PyreOfHeroesEffect(), new GenericManaCost(2) + ); + ability.addCost(new TapSourceCost()); + ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent( + StaticFilters.FILTER_CONTROLLED_CREATURE_SHORT_TEXT + ))); + this.addAbility(ability); + } + + private PyreOfHeroes(final PyreOfHeroes card) { + super(card); + } + + @Override + public PyreOfHeroes copy() { + return new PyreOfHeroes(this); + } +} + +class PyreOfHeroesEffect extends OneShotEffect { + + PyreOfHeroesEffect() { + super(Outcome.Benefit); + staticText = "Search your library for a creature card that shares a creature type with the sacrificed creature and has converted mana cost equal to 1 " + + "plus that creature's converted mana cost. Put that card " + + "onto the battlefield, then shuffle your library"; + } + + private PyreOfHeroesEffect(final PyreOfHeroesEffect 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(CardType.CREATURE.getPredicate()); + filter.add(new PyreOfHeroesPredicate(sacrificedPermanent)); + TargetCardInLibrary target = new TargetCardInLibrary(filter); + if (controller.searchLibrary(target, source, game)) { + Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); + } + controller.shuffleLibrary(source, game); + return true; + } + + @Override + public PyreOfHeroesEffect copy() { + return new PyreOfHeroesEffect(this); + } +} + +class PyreOfHeroesPredicate implements Predicate { + + private final Permanent sacrificedPermanent; + + public PyreOfHeroesPredicate(Permanent sacrificedPermanent) { + this.sacrificedPermanent = sacrificedPermanent; + } + + @Override + public boolean apply(MageObject input, Game game) { + return input.shareCreatureTypes(sacrificedPermanent, game); + } + + @Override + public String toString() { + return "shares a creature type"; + } +} diff --git a/Mage.Sets/src/mage/sets/Kaldheim.java b/Mage.Sets/src/mage/sets/Kaldheim.java index da078d6c60e..d927b31708c 100644 --- a/Mage.Sets/src/mage/sets/Kaldheim.java +++ b/Mage.Sets/src/mage/sets/Kaldheim.java @@ -43,6 +43,7 @@ public final class Kaldheim extends ExpansionSet { cards.add(new SetCardInfo("Gilded Assault Cart", 390, Rarity.UNCOMMON, mage.cards.g.GildedAssaultCart.class)); cards.add(new SetCardInfo("Gladewalker Ritualist", 392, Rarity.UNCOMMON, mage.cards.g.GladewalkerRitualist.class)); cards.add(new SetCardInfo("Hengegate Pathway", 260, Rarity.RARE, mage.cards.h.HengegatePathway.class)); + cards.add(new SetCardInfo("Pyre of Heroes", 241, Rarity.RARE, mage.cards.p.PyreOfHeroes.class)); cards.add(new SetCardInfo("Rampage of the Valkyries", 393, Rarity.UNCOMMON, mage.cards.r.RampageOfTheValkyries.class)); cards.add(new SetCardInfo("Realmwalker", 188, Rarity.RARE, mage.cards.r.Realmwalker.class)); cards.add(new SetCardInfo("Renegade Reaper", 386, Rarity.UNCOMMON, mage.cards.r.RenegadeReaper.class));