diff --git a/Mage.Sets/src/mage/cards/i/InSearchOfGreatness.java b/Mage.Sets/src/mage/cards/i/InSearchOfGreatness.java new file mode 100644 index 0000000000..8ba640a75b --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/InSearchOfGreatness.java @@ -0,0 +1,103 @@ +package mage.cards.i; + +import java.util.UUID; + +import mage.ApprovingObject; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.common.FilterPermanentCard; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCardInHand; + +/** + * + * @author weirddan455 + */ +public final class InSearchOfGreatness extends CardImpl { + + public InSearchOfGreatness(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{G}{G}"); + + // At the beginning of your upkeep, you may cast a permanent spell from your hand with converted mana cost + // equal to 1 plus the highest converted mana cost among other permanents you control + // without paying its mana cost. If you don't, scry 1. + this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new InSearchOfGreatnessEffect(), + TargetController.YOU, false, false + )); + } + + private InSearchOfGreatness(final InSearchOfGreatness card) { + super(card); + } + + @Override + public InSearchOfGreatness copy() { + return new InSearchOfGreatness(this); + } +} + +class InSearchOfGreatnessEffect extends OneShotEffect { + + public InSearchOfGreatnessEffect() { + super(Outcome.PlayForFree); + staticText = "you may cast a permanent spell from your hand with converted mana cost " + + "equal to 1 plus the highest converted mana cost among other permanents you control " + + "without paying its mana cost. If you don't, scry 1"; + } + + private InSearchOfGreatnessEffect(final InSearchOfGreatnessEffect effect) { + super(effect); + } + + @Override + public InSearchOfGreatnessEffect copy() { + return new InSearchOfGreatnessEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + int cmc = 0; + UUID permId = source.getSourceId(); + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(controller.getId())) { + if (permanent != null && !permanent.getId().equals(permId)) { + int permCmc = permanent.getConvertedManaCost(); + if (permCmc > cmc) { + cmc = permCmc; + } + } + } + if (controller.chooseUse(outcome, "Cast a permanent spell from your hand with CMC equal to " + + ++cmc + "?", source, game)) { + FilterPermanentCard filter = new FilterPermanentCard("permanent spell from your hand"); + filter.add(Predicates.not(CardType.LAND.getPredicate())); + filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, cmc)); + TargetCardInHand target = new TargetCardInHand(filter); + if (controller.chooseTarget(outcome, target, source, game)) { + Card card = game.getCard(target.getFirstTarget()); + if (card != null) { + game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE); + boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), + game, true, new ApprovingObject(source, game)); + game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null); + if (cardWasCast) { + return true; + } + } + } + } + return controller.scry(1, source, game); + } +} diff --git a/Mage.Sets/src/mage/sets/Kaldheim.java b/Mage.Sets/src/mage/sets/Kaldheim.java index 9546c39e10..d4d4f71d36 100644 --- a/Mage.Sets/src/mage/sets/Kaldheim.java +++ b/Mage.Sets/src/mage/sets/Kaldheim.java @@ -169,6 +169,7 @@ public final class Kaldheim extends ExpansionSet { cards.add(new SetCardInfo("Highland Forest", 261, Rarity.COMMON, mage.cards.h.HighlandForest.class)); cards.add(new SetCardInfo("Horizon Seeker", 175, Rarity.COMMON, mage.cards.h.HorizonSeeker.class)); cards.add(new SetCardInfo("Ice Tunnel", 262, Rarity.COMMON, mage.cards.i.IceTunnel.class)); + cards.add(new SetCardInfo("In Search of Greatness", 364, Rarity.RARE, mage.cards.i.InSearchOfGreatness.class)); cards.add(new SetCardInfo("Icehide Troll", 176, Rarity.COMMON, mage.cards.i.IcehideTroll.class)); cards.add(new SetCardInfo("Immersturm Predator", 214, Rarity.RARE, mage.cards.i.ImmersturmPredator.class)); cards.add(new SetCardInfo("Infernal Pet", 99, Rarity.COMMON, mage.cards.i.InfernalPet.class));