[STX] Implemented Elemental Expression

This commit is contained in:
Evan Kranzler 2021-04-10 18:09:55 -04:00
parent 421d092616
commit ae949a48b8
2 changed files with 131 additions and 0 deletions

View file

@ -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.";
}
}

View file

@ -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));