From 63ae80c711a15fc851657afc4150bfd446f90455 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 10 Apr 2021 21:37:46 -0400 Subject: [PATCH] [STX] Implemented Ingenious Mastery --- .../src/mage/cards/i/IngeniousMastery.java | 90 +++++++++++++++++++ .../mage/sets/StrixhavenSchoolOfMages.java | 1 + 2 files changed, 91 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/i/IngeniousMastery.java diff --git a/Mage.Sets/src/mage/cards/i/IngeniousMastery.java b/Mage.Sets/src/mage/cards/i/IngeniousMastery.java new file mode 100644 index 00000000000..64f58a06c11 --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/IngeniousMastery.java @@ -0,0 +1,90 @@ +package mage.cards.i; + +import mage.abilities.Ability; +import mage.abilities.costs.AlternativeCostSourceAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.token.TreasureToken; +import mage.players.Player; +import mage.target.common.TargetOpponent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class IngeniousMastery extends CardImpl { + + public IngeniousMastery(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{2}{U}"); + + // You may pay {2}{U} rather than pay this spell's mana cost. + Ability costAbility = new AlternativeCostSourceAbility(new ManaCostsImpl<>("{2}{U}")); + this.addAbility(costAbility); + + // If the {2}{U} cost was paid, you draw three cards, then an opponent creates two Treasure tokens and they scry 2. If that cost wasn't paid, you draw X cards. + this.getSpellAbility().addEffect(new IngeniousMasteryEffect(costAbility.getOriginalId())); + } + + private IngeniousMastery(final IngeniousMastery card) { + super(card); + } + + @Override + public IngeniousMastery copy() { + return new IngeniousMastery(this); + } +} + +class IngeniousMasteryEffect extends OneShotEffect { + + private final UUID alternativeCostOriginalID; + + IngeniousMasteryEffect(UUID alternativeCostOriginalID) { + super(Outcome.Detriment); + staticText = "if the {2}{U} cost was paid, you draw three cards, then an opponent creates " + + "two Treasure tokens and they scry 2. If that cost wasn't paid, you draw X cards"; + this.alternativeCostOriginalID = alternativeCostOriginalID; + } + + private IngeniousMasteryEffect(IngeniousMasteryEffect effect) { + super(effect); + this.alternativeCostOriginalID = effect.alternativeCostOriginalID; + } + + @Override + public IngeniousMasteryEffect copy() { + return new IngeniousMasteryEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + if (!AlternativeCostSourceAbility.getActivatedStatus( + game, source, this.alternativeCostOriginalID, false + )) { + return player.drawCards(source.getManaCostsToPay().getX(), source, game) > 0; + } + + player.drawCards(3, source, game); + TargetOpponent targetOpponent = new TargetOpponent(true); + if (!player.chooseTarget(Outcome.DrawCard, targetOpponent, source, game)) { + return false; + } + Player opponent = game.getPlayer(targetOpponent.getFirstTarget()); + if (opponent == null) { + return false; + } + new TreasureToken().putOntoBattlefield(2, game, source, opponent.getId()); + opponent.scry(2, source, game); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java index 341d2e1a39d..0ba6abc575e 100644 --- a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java +++ b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java @@ -141,6 +141,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet { cards.add(new SetCardInfo("Illuminate History", 108, Rarity.RARE, mage.cards.i.IlluminateHistory.class)); cards.add(new SetCardInfo("Illustrious Historian", 109, Rarity.COMMON, mage.cards.i.IllustriousHistorian.class)); cards.add(new SetCardInfo("Infuse with Vitality", 194, Rarity.COMMON, mage.cards.i.InfuseWithVitality.class)); + cards.add(new SetCardInfo("Ingenious Mastery", 44, Rarity.RARE, mage.cards.i.IngeniousMastery.class)); cards.add(new SetCardInfo("Inkling Summoning", 195, Rarity.COMMON, mage.cards.i.InklingSummoning.class)); cards.add(new SetCardInfo("Introduction to Annihilation", 3, Rarity.COMMON, mage.cards.i.IntroductionToAnnihilation.class)); cards.add(new SetCardInfo("Introduction to Prophecy", 4, Rarity.COMMON, mage.cards.i.IntroductionToProphecy.class));