diff --git a/Mage.Sets/src/mage/cards/w/WildwoodEscort.java b/Mage.Sets/src/mage/cards/w/WildwoodEscort.java new file mode 100644 index 0000000000..6b768baee2 --- /dev/null +++ b/Mage.Sets/src/mage/cards/w/WildwoodEscort.java @@ -0,0 +1,97 @@ +package mage.cards.w; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterCard; +import mage.filter.predicate.Predicates; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.target.common.TargetCardInYourGraveyard; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class WildwoodEscort extends CardImpl { + + private static final FilterCard filter = new FilterCard("creature or battle card from your graveyard"); + + static { + filter.add(Predicates.or( + CardType.CREATURE.getPredicate(), + CardType.BATTLE.getPredicate() + )); + } + + public WildwoodEscort(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{G}"); + + this.subtype.add(SubType.ELF); + this.subtype.add(SubType.WARRIOR); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // When Wildwood Escort enters the battlefield, return target creature or battle card from your graveyard to your hand. + Ability ability = new EntersBattlefieldTriggeredAbility(new ReturnFromGraveyardToHandTargetEffect()); + ability.addTarget(new TargetCardInYourGraveyard(filter)); + this.addAbility(ability); + + // If Wildwood Escort would die, exile it instead. + this.addAbility(new SimpleStaticAbility(new WildwoodEscortEffect())); + } + + private WildwoodEscort(final WildwoodEscort card) { + super(card); + } + + @Override + public WildwoodEscort copy() { + return new WildwoodEscort(this); + } +} + +class WildwoodEscortEffect extends ReplacementEffectImpl { + + public WildwoodEscortEffect() { + super(Duration.WhileOnBattlefield, Outcome.Exile); + staticText = "if {this} would die, exile it instead"; + } + + public WildwoodEscortEffect(final WildwoodEscortEffect effect) { + super(effect); + } + + @Override + public WildwoodEscortEffect copy() { + return new WildwoodEscortEffect(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) { + if (!event.getTargetId().equals(source.getSourceId())) { + return false; + } + ZoneChangeEvent zce = (ZoneChangeEvent) event; + return zce.isDiesEvent(); + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index e9e926fab1..22abce0fac 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -206,6 +206,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Voldaren Thrillseeker", 171, Rarity.RARE, mage.cards.v.VoldarenThrillseeker.class)); cards.add(new SetCardInfo("War Historian", 214, Rarity.COMMON, mage.cards.w.WarHistorian.class)); cards.add(new SetCardInfo("Wary Thespian", 215, Rarity.COMMON, mage.cards.w.WaryThespian.class)); + cards.add(new SetCardInfo("Wildwood Escort", 216, Rarity.COMMON, mage.cards.w.WildwoodEscort.class)); cards.add(new SetCardInfo("Wind-Scarred Crag", 276, Rarity.COMMON, mage.cards.w.WindScarredCrag.class)); cards.add(new SetCardInfo("Wrenn and Realmbreaker", 217, Rarity.MYTHIC, mage.cards.w.WrennAndRealmbreaker.class)); cards.add(new SetCardInfo("Wrenn's Resolve", 173, Rarity.COMMON, mage.cards.w.WrennsResolve.class));