From 9cac95d3deacc2bd672d491b2debeee41d87076a Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 29 Aug 2022 08:38:12 -0400 Subject: [PATCH] [DMU] Implemented Founding the Third Path --- .../mage/cards/f/FoundingTheThirdPath.java | 108 ++++++++++++++++++ Mage.Sets/src/mage/sets/DominariaUnited.java | 1 + 2 files changed, 109 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/f/FoundingTheThirdPath.java diff --git a/Mage.Sets/src/mage/cards/f/FoundingTheThirdPath.java b/Mage.Sets/src/mage/cards/f/FoundingTheThirdPath.java new file mode 100644 index 00000000000..132da7bcdaf --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FoundingTheThirdPath.java @@ -0,0 +1,108 @@ +package mage.cards.f; + +import mage.ApprovingObject; +import mage.abilities.Ability; +import mage.abilities.common.SagaAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.MillCardsTargetEffect; +import mage.abilities.effects.common.cost.CastFromHandForFreeEffect; +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.common.FilterInstantOrSorceryCard; +import mage.filter.predicate.mageobject.ManaValuePredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetPlayer; +import mage.target.common.TargetCardInYourGraveyard; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class FoundingTheThirdPath extends CardImpl { + + private static final FilterCard filter + = new FilterInstantOrSorceryCard("an instant or sorcery spell with mana value 1 or 2"); + + static { + filter.add(new ManaValuePredicate(ComparisonType.MORE_THAN, 0)); + filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 3)); + } + + public FoundingTheThirdPath(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}"); + + this.subtype.add(SubType.SAGA); + + // Read ahead + SagaAbility sagaAbility = new SagaAbility(this, SagaChapter.CHAPTER_III, true); + + // I -- You may cast an instant or sorcery spell with mana value 1 or 2 from your hand without paying its mana cost. + sagaAbility.addChapterEffect(this, SagaChapter.CHAPTER_I, new CastFromHandForFreeEffect(filter)); + + // II -- Target player mills four cards. + sagaAbility.addChapterEffect( + this, SagaChapter.CHAPTER_II, SagaChapter.CHAPTER_II, + new MillCardsTargetEffect(4), new TargetPlayer() + ); + + // III -- Exile target instant or sorcery card from your graveyard. Copy it. You may cast the copy. + sagaAbility.addChapterEffect( + this, SagaChapter.CHAPTER_III, SagaChapter.CHAPTER_III, + new FoundingTheThirdPathEffect(), + new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY_FROM_YOUR_GRAVEYARD) + ); + } + + private FoundingTheThirdPath(final FoundingTheThirdPath card) { + super(card); + } + + @Override + public FoundingTheThirdPath copy() { + return new FoundingTheThirdPath(this); + } +} + +class FoundingTheThirdPathEffect extends OneShotEffect { + + FoundingTheThirdPathEffect() { + super(Outcome.Benefit); + staticText = "exile target instant or sorcery card from your graveyard. Copy it. You may cast the copy"; + } + + private FoundingTheThirdPathEffect(final FoundingTheThirdPathEffect effect) { + super(effect); + } + + @Override + public FoundingTheThirdPathEffect copy() { + return new FoundingTheThirdPathEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Card card = game.getCard(getTargetPointer().getFirst(game, source)); + if (controller == null || card == null) { + return false; + } + controller.moveCards(card, Zone.EXILED, source, game); + if (!controller.chooseUse(outcome, "Cast copy of " + card.getName() + '?', source, game)) { + return true; + } + Card copiedCard = game.copyCard(card, source, controller.getId()); + game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), Boolean.TRUE); + controller.cast( + controller.chooseAbilityForCast(copiedCard, game, false), + game, false, new ApprovingObject(source, game) + ); + game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), null); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/DominariaUnited.java b/Mage.Sets/src/mage/sets/DominariaUnited.java index 00ba3db8d69..c69ad07cf98 100644 --- a/Mage.Sets/src/mage/sets/DominariaUnited.java +++ b/Mage.Sets/src/mage/sets/DominariaUnited.java @@ -95,6 +95,7 @@ public final class DominariaUnited extends ExpansionSet { cards.add(new SetCardInfo("Flowstone Infusion", 124, Rarity.COMMON, mage.cards.f.FlowstoneInfusion.class)); cards.add(new SetCardInfo("Flowstone Kavu", 125, Rarity.COMMON, mage.cards.f.FlowstoneKavu.class)); cards.add(new SetCardInfo("Forest", 274, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Founding the Third Path", 50, Rarity.UNCOMMON, mage.cards.f.FoundingTheThirdPath.class)); cards.add(new SetCardInfo("Frostfist Strider", 51, Rarity.UNCOMMON, mage.cards.f.FrostfistStrider.class)); cards.add(new SetCardInfo("Furious Bellow", 126, Rarity.COMMON, mage.cards.f.FuriousBellow.class)); cards.add(new SetCardInfo("Gaea's Might", 164, Rarity.COMMON, mage.cards.g.GaeasMight.class));