From ae949a48b854936d2481d02187c1e755f2ef5c7e Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 10 Apr 2021 18:09:55 -0400 Subject: [PATCH] [STX] Implemented Elemental Expression --- .../mage/cards/e/ElementalExpressionist.java | 130 ++++++++++++++++++ .../mage/sets/StrixhavenSchoolOfMages.java | 1 + 2 files changed, 131 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/e/ElementalExpressionist.java diff --git a/Mage.Sets/src/mage/cards/e/ElementalExpressionist.java b/Mage.Sets/src/mage/cards/e/ElementalExpressionist.java new file mode 100644 index 00000000000..ef5c4b95021 --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/ElementalExpressionist.java @@ -0,0 +1,130 @@ +package mage.cards.e; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.MagecraftAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.common.ZoneChangeTriggeredAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.token.PrismariToken; +import mage.target.common.TargetControlledCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ElementalExpressionist extends CardImpl { + + public ElementalExpressionist(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U/R}{U/R}{U/R}{U/R}"); + + this.subtype.add(SubType.ORC); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Magecraft — Whenever you cast or copy an instant or sorcery spell, choose target creature you control. Until end of turn, it gains "If this creature would leave the battlefield, exile it instead of putting it anywhere else" and "When you exile this creature, create a 4/4 blue and red Elemental creature token." + Ability ability = new MagecraftAbility(new GainAbilityTargetEffect( + new SimpleStaticAbility(new ElementalExpressionistReplacementEffect()), + Duration.EndOfTurn, "choose target creature you control. Until end of turn, " + + "it gains \"If this creature would leave the battlefield, exile it instead of putting it anywhere else\"" + )); + ability.addEffect(new GainAbilityTargetEffect( + new ElementalExpressionistTriggeredAbility(), Duration.EndOfTurn, + "and \"When you exile this creature, create a 4/4 blue and red Elemental creature token.\"" + )); + ability.addTarget(new TargetControlledCreaturePermanent()); + this.addAbility(ability); + } + + private ElementalExpressionist(final ElementalExpressionist card) { + super(card); + } + + @Override + public ElementalExpressionist copy() { + return new ElementalExpressionist(this); + } +} + +class ElementalExpressionistReplacementEffect extends ReplacementEffectImpl { + + ElementalExpressionistReplacementEffect() { + super(Duration.WhileOnBattlefield, Outcome.Tap); + staticText = "If this creature would leave the battlefield, exile it instead of putting it anywhere else"; + } + + private ElementalExpressionistReplacementEffect(final ElementalExpressionistReplacementEffect effect) { + super(effect); + } + + @Override + public ElementalExpressionistReplacementEffect copy() { + return new ElementalExpressionistReplacementEffect(this); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + ((ZoneChangeEvent) event).setToZone(Zone.EXILED); + return false; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ZONE_CHANGE; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return event.getTargetId().equals(source.getSourceId()) + && ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD + && ((ZoneChangeEvent) event).getToZone() != Zone.EXILED; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } +} + +class ElementalExpressionistTriggeredAbility extends ZoneChangeTriggeredAbility { + + ElementalExpressionistTriggeredAbility() { + super(Zone.BATTLEFIELD, Zone.BATTLEFIELD, Zone.EXILED, new CreateTokenEffect(new PrismariToken()), "", false); + } + + private ElementalExpressionistTriggeredAbility(final ElementalExpressionistTriggeredAbility ability) { + super(ability); + } + + @Override + public ElementalExpressionistTriggeredAbility copy() { + return new ElementalExpressionistTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + // TODO: this needs to check that the controller exiled it, currently not supported + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + if (zEvent.getTarget() == null || zEvent.getTarget() != getSourcePermanentOrLKI(game)) { + return false; + } + // custom check cause ZoneChangeTriggeredAbility for source object only + return (fromZone == null || zEvent.getFromZone() == fromZone) + && (zEvent.getToZone() == toZone || zEvent.getOriginalToZone() == toZone); + } + + @Override + public String getRule() { + return "When you exile this creature, create a 4/4 blue and red Elemental creature token."; + } +} diff --git a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java index 8413504d771..ae2f5c3414f 100644 --- a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java +++ b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java @@ -95,6 +95,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet { cards.add(new SetCardInfo("Dream Strix", 42, Rarity.RARE, mage.cards.d.DreamStrix.class)); cards.add(new SetCardInfo("Dueling Coach", 15, Rarity.UNCOMMON, mage.cards.d.DuelingCoach.class)); cards.add(new SetCardInfo("Eager First-Year", 16, Rarity.COMMON, mage.cards.e.EagerFirstYear.class)); + cards.add(new SetCardInfo("Elemental Expressionist", 181, Rarity.RARE, mage.cards.e.ElementalExpressionist.class)); cards.add(new SetCardInfo("Elemental Masterpiece", 182, Rarity.COMMON, mage.cards.e.ElementalMasterpiece.class)); cards.add(new SetCardInfo("Elemental Summoning", 183, Rarity.COMMON, mage.cards.e.ElementalSummoning.class)); cards.add(new SetCardInfo("Emergent Sequence", 129, Rarity.UNCOMMON, mage.cards.e.EmergentSequence.class));