From fd64ed884948ed4ffdc5965acf5966de66bc12f5 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Mon, 8 May 2023 20:03:25 -0400 Subject: [PATCH] [MAT] Implement Tranquil Frillback --- .../src/mage/cards/t/TranquilFrillback.java | 106 ++++++++++++++++++ .../sets/MarchOfTheMachineTheAftermath.java | 1 + 2 files changed, 107 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TranquilFrillback.java diff --git a/Mage.Sets/src/mage/cards/t/TranquilFrillback.java b/Mage.Sets/src/mage/cards/t/TranquilFrillback.java new file mode 100644 index 00000000000..cddfedbb15a --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TranquilFrillback.java @@ -0,0 +1,106 @@ +package mage.cards.t; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.delayed.ReflexiveTriggeredAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.effects.common.ExileGraveyardAllTargetPlayerEffect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.TargetPlayer; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TranquilFrillback extends CardImpl { + + public TranquilFrillback(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}"); + + this.subtype.add(SubType.DINOSAUR); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // When Tranquil Frillback enters the battlefield, you may pay {G} up to three times. When you pay this cost one or more times, choose up to that many-- + // * Destroy target artifact or enchantment. + // * Exile target player's graveyard. + // * You gain 4 life. + this.addAbility(new EntersBattlefieldTriggeredAbility(new TranquilFrillbackEffect())); + } + + private TranquilFrillback(final TranquilFrillback card) { + super(card); + } + + @Override + public TranquilFrillback copy() { + return new TranquilFrillback(this); + } +} + +class TranquilFrillbackEffect extends OneShotEffect { + + private static ReflexiveTriggeredAbility makeAbility() { + ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DestroyTargetEffect(), false); + ability.addTarget(new TargetPermanent(StaticFilters.FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT)); + ability.addMode(new Mode(new ExileGraveyardAllTargetPlayerEffect()).addTarget(new TargetPlayer())); + ability.addMode(new Mode(new GainLifeEffect(4))); + ability.getModes().setMinModes(0); + ability.getModes().setChooseText("choose up to that many —"); + return ability; + } + + TranquilFrillbackEffect() { + super(Outcome.Benefit); + staticText = "you may pay {G} up to three times. " + + "When you pay this cost one or more times, " + makeAbility().getRule(); + } + + private TranquilFrillbackEffect(final TranquilFrillbackEffect effect) { + super(effect); + } + + @Override + public TranquilFrillbackEffect copy() { + return new TranquilFrillbackEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + int count = 0; + for (int i = 0; i < 3; i++) { + Cost cost = new ManaCostsImpl<>("{G}"); + if (!cost.canPay(source, source, source.getControllerId(), game) + || !cost.pay(source, game, source, source.getControllerId(), false)) { + break; + } + count++; + } + if (count < 1) { + return false; + } + ReflexiveTriggeredAbility ability = makeAbility(); + ability.getModes().setMaxModes(count); + game.fireReflexiveTriggeredAbility(ability, source); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java b/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java index 34d79ebb286..7540cb9e456 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachineTheAftermath.java @@ -62,6 +62,7 @@ public final class MarchOfTheMachineTheAftermath extends ExpansionSet { cards.add(new SetCardInfo("The Kenriths' Royal Funeral", 34, Rarity.RARE, mage.cards.t.TheKenrithsRoyalFuneral.class)); cards.add(new SetCardInfo("Tolarian Contempt", 8, Rarity.UNCOMMON, mage.cards.t.TolarianContempt.class)); cards.add(new SetCardInfo("Training Grounds", 9, Rarity.RARE, mage.cards.t.TrainingGrounds.class)); + cards.add(new SetCardInfo("Tranquil Frillback", 24, Rarity.RARE, mage.cards.t.TranquilFrillback.class)); cards.add(new SetCardInfo("Tyvar the Bellicose", 48, Rarity.MYTHIC, mage.cards.t.TyvarTheBellicose.class)); cards.add(new SetCardInfo("Undercity Upheaval", 25, Rarity.UNCOMMON, mage.cards.u.UndercityUpheaval.class)); cards.add(new SetCardInfo("Urborg Scavengers", 15, Rarity.RARE, mage.cards.u.UrborgScavengers.class));