From 730ac37930617a4bbefd4858c154d0b35e888ca5 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 27 Mar 2021 08:06:26 -0400 Subject: [PATCH] [STX] Implemented Prismari Apprentice --- .../src/mage/cards/p/PrismariApprentice.java | 61 +++++++++++++++++++ .../mage/sets/StrixhavenSchoolOfMages.java | 1 + .../abilities/common/MagecraftAbility.java | 10 ++- 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/p/PrismariApprentice.java diff --git a/Mage.Sets/src/mage/cards/p/PrismariApprentice.java b/Mage.Sets/src/mage/cards/p/PrismariApprentice.java new file mode 100644 index 0000000000..5d456f26bb --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PrismariApprentice.java @@ -0,0 +1,61 @@ +package mage.cards.p; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.MagecraftAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.common.combat.CantBeBlockedSourceEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.stack.Spell; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PrismariApprentice extends CardImpl { + + public PrismariApprentice(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}{R}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.SHAMAN); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Magecraft — Whenever you cast or copy an instant or sorcery spell, Prismari Apprentice can't be blocked this turn. If that spell has mana value 5 or greater, put a +1/+1 counter on Prismari Apprentice. + Ability ability = new MagecraftAbility(new CantBeBlockedSourceEffect(Duration.EndOfTurn)); + ability.addEffect(new ConditionalOneShotEffect(new AddCountersSourceEffect( + CounterType.P1P1.createInstance()), PrismariApprenticeCondition.instance, + "If that spell has mana value 5 or greater, put a +1/+1 counter on {this}" + )); + this.addAbility(ability); + } + + private PrismariApprentice(final PrismariApprentice card) { + super(card); + } + + @Override + public PrismariApprentice copy() { + return new PrismariApprentice(this); + } +} + +enum PrismariApprenticeCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + Spell spell = (Spell) source.getEffects().get(0).getValue(MagecraftAbility.SPELL_KEY); + return spell != null && spell.getConvertedManaCost() >= 5; + } +} diff --git a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java index 17a410aa04..b823570dc9 100644 --- a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java +++ b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java @@ -50,6 +50,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet { cards.add(new SetCardInfo("Plains", 366, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Plains", 367, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Pop Quiz", 49, Rarity.COMMON, mage.cards.p.PopQuiz.class)); + cards.add(new SetCardInfo("Prismari Apprentice", 213, Rarity.UNCOMMON, mage.cards.p.PrismariApprentice.class)); cards.add(new SetCardInfo("Prismari Command", 214, Rarity.RARE, mage.cards.p.PrismariCommand.class)); cards.add(new SetCardInfo("Professor Onyx", 83, Rarity.MYTHIC, mage.cards.p.ProfessorOnyx.class)); cards.add(new SetCardInfo("Professor of Symbology", 24, Rarity.UNCOMMON, mage.cards.p.ProfessorOfSymbology.class)); diff --git a/Mage/src/main/java/mage/abilities/common/MagecraftAbility.java b/Mage/src/main/java/mage/abilities/common/MagecraftAbility.java index 8929da79ca..f88fe3a48c 100644 --- a/Mage/src/main/java/mage/abilities/common/MagecraftAbility.java +++ b/Mage/src/main/java/mage/abilities/common/MagecraftAbility.java @@ -12,6 +12,8 @@ import mage.game.stack.Spell; */ public class MagecraftAbility extends TriggeredAbilityImpl { + public static final String SPELL_KEY = "castCopiedSpell"; + public MagecraftAbility(Effect effect) { this(effect, false); } @@ -33,7 +35,13 @@ public class MagecraftAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { Spell spell = game.getSpell(event.getTargetId()); - return spell != null && spell.isControlledBy(getControllerId()) && spell.isInstantOrSorcery(); + if (spell == null + || !spell.isControlledBy(getControllerId()) + || !spell.isInstantOrSorcery()) { + return false; + } + getEffects().setValue(SPELL_KEY, spell); + return true; } @Override