From ad0c75895fd5ffbc68f4ee5ea432650d11ce9de8 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 18 Apr 2020 18:59:48 -0400 Subject: [PATCH] Implemented Ethereal Forager --- .../src/mage/cards/e/EtherealForager.java | 96 +++++++++++++++++++ .../src/mage/sets/Commander2020Edition.java | 1 + 2 files changed, 97 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/e/EtherealForager.java diff --git a/Mage.Sets/src/mage/cards/e/EtherealForager.java b/Mage.Sets/src/mage/cards/e/EtherealForager.java new file mode 100644 index 0000000000..d39ba59c8c --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/EtherealForager.java @@ -0,0 +1,96 @@ +package mage.cards.e; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.DelveAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetCardInExile; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class EtherealForager extends CardImpl { + + public EtherealForager(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{U}{U}"); + + this.subtype.add(SubType.ELEMENTAL); + this.subtype.add(SubType.WHALE); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // Delve + this.addAbility(new DelveAbility()); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Whenever Ethereal Forager attacks, you may return an instant or sorcery card exiled with Ethereal Forager to its owner's hand. + this.addAbility(new AttacksTriggeredAbility(new EtherealForagerEffect(), true)); + } + + private EtherealForager(final EtherealForager card) { + super(card); + } + + @Override + public EtherealForager copy() { + return new EtherealForager(this); + } +} + +class EtherealForagerEffect extends OneShotEffect { + + EtherealForagerEffect() { + super(Outcome.Benefit); + staticText = "return an instant or sorcery card exiled with {this} to its owner's hand"; + } + + private EtherealForagerEffect(final EtherealForagerEffect effect) { + super(effect); + } + + @Override + public EtherealForagerEffect copy() { + return new EtherealForagerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + String keyString = CardUtil.getCardZoneString("delvedCards", source.getSourceId(), game, true); + Cards delvedCards = (Cards) game.getState().getValue(keyString); + if (delvedCards == null || delvedCards.count(StaticFilters.FILTER_CARD_INSTANT_AND_SORCERY, game) < 1) { + return false; + } + TargetCard targetCard = new TargetCardInExile(0, 1, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY, null, true); + ; + player.choose(Outcome.DrawCard, delvedCards, targetCard, game); + Card card = game.getCard(targetCard.getFirstTarget()); + if (card == null || !player.moveCards(card, Zone.HAND, source, game)) { + return false; + } + delvedCards.remove(card); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2020Edition.java b/Mage.Sets/src/mage/sets/Commander2020Edition.java index f3e344aadf..dba4d172a5 100644 --- a/Mage.Sets/src/mage/sets/Commander2020Edition.java +++ b/Mage.Sets/src/mage/sets/Commander2020Edition.java @@ -124,6 +124,7 @@ public final class Commander2020Edition extends ExpansionSet { cards.add(new SetCardInfo("Eon Frolicker", 33, Rarity.RARE, mage.cards.e.EonFrolicker.class)); cards.add(new SetCardInfo("Etali, Primal Storm", 151, Rarity.RARE, mage.cards.e.EtaliPrimalStorm.class)); cards.add(new SetCardInfo("Eternal Dragon", 88, Rarity.RARE, mage.cards.e.EternalDragon.class)); + cards.add(new SetCardInfo("Ethereal Forager", 34, Rarity.RARE, mage.cards.e.EtherealForager.class)); cards.add(new SetCardInfo("Ever After", 133, Rarity.RARE, mage.cards.e.EverAfter.class)); cards.add(new SetCardInfo("Evolution Charm", 171, Rarity.COMMON, mage.cards.e.EvolutionCharm.class)); cards.add(new SetCardInfo("Exotic Orchard", 273, Rarity.RARE, mage.cards.e.ExoticOrchard.class));