diff --git a/Mage.Sets/src/mage/cards/e/EowynFearlessKnight.java b/Mage.Sets/src/mage/cards/e/EowynFearlessKnight.java new file mode 100644 index 0000000000..007d148163 --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/EowynFearlessKnight.java @@ -0,0 +1,114 @@ +package mage.cards.e; + +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.abilities.keyword.HasteAbility; +import mage.abilities.keyword.ProtectionAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.common.FilterOpponentsCreaturePermanent; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; + +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class EowynFearlessKnight extends CardImpl { + + private static final FilterPermanent filter + = new FilterOpponentsCreaturePermanent("creature an opponent controls with greater power"); + + static { + filter.add(EowynFearlessKnightPredicate.instance); + } + + public EowynFearlessKnight(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}{W}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.KNIGHT); + this.power = new MageInt(3); + this.toughness = new MageInt(4); + + // Haste + this.addAbility(HasteAbility.getInstance()); + + // When Eowyn, Fearless Knight enters the battlefield, exile target creature an opponent controls with greater power. Legendary creatures you control gain protection from each of that creature's colors until end of turn. + Ability ability = new EntersBattlefieldTriggeredAbility(new EowynFearlessKnightEffect()); + ability.addTarget(new TargetPermanent(filter)); + this.addAbility(ability); + } + + private EowynFearlessKnight(final EowynFearlessKnight card) { + super(card); + } + + @Override + public EowynFearlessKnight copy() { + return new EowynFearlessKnight(this); + } +} + +enum EowynFearlessKnightPredicate implements ObjectSourcePlayerPredicate { + instance; + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + return Optional + .ofNullable(input.getSource().getSourcePermanentOrLKI(game)) + .filter(Objects::nonNull) + .map(permanent -> permanent.getPower().getValue() + < input.getObject().getPower().getValue()).orElse(false); + } +} + +class EowynFearlessKnightEffect extends OneShotEffect { + + EowynFearlessKnightEffect() { + super(Outcome.Benefit); + staticText = "exile target creature an opponent controls with greater power. Legendary creatures " + + "you control gain protection from each of that creature's colors until end of turn"; + } + + private EowynFearlessKnightEffect(final EowynFearlessKnightEffect effect) { + super(effect); + } + + @Override + public EowynFearlessKnightEffect copy() { + return new EowynFearlessKnightEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (player == null || permanent == null) { + return false; + } + player.moveCards(permanent, Zone.EXILED, source, game); + for (ObjectColor color : permanent.getColor(game).getColors()) { + game.addEffect(new GainAbilityControlledEffect( + ProtectionAbility.from(color), Duration.EndOfTurn, + StaticFilters.FILTER_CREATURE_LEGENDARY + ), source); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java index 0653f2d079..e2f8456edc 100644 --- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java +++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java @@ -37,6 +37,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet { cards.add(new SetCardInfo("Dunedain Blade", 6, Rarity.COMMON, mage.cards.d.DunedainBlade.class)); cards.add(new SetCardInfo("Easterling Vanguard", 83, Rarity.COMMON, mage.cards.e.EasterlingVanguard.class)); cards.add(new SetCardInfo("Eastfarthing Farmer", 8, Rarity.COMMON, mage.cards.e.EastfarthingFarmer.class)); + cards.add(new SetCardInfo("Eowyn, Fearless Knight", 201, Rarity.RARE, mage.cards.e.EowynFearlessKnight.class)); cards.add(new SetCardInfo("Fall of Gil-galad", 165, Rarity.RARE, mage.cards.f.FallOfGilGalad.class)); cards.add(new SetCardInfo("Fire of Orthanc", 127, Rarity.COMMON, mage.cards.f.FireOfOrthanc.class)); cards.add(new SetCardInfo("Foray of Orcs", 128, Rarity.UNCOMMON, mage.cards.f.ForayOfOrcs.class)); diff --git a/Mage/src/main/java/mage/filter/StaticFilters.java b/Mage/src/main/java/mage/filter/StaticFilters.java index 9b7da80441..71f6c920e5 100644 --- a/Mage/src/main/java/mage/filter/StaticFilters.java +++ b/Mage/src/main/java/mage/filter/StaticFilters.java @@ -1089,6 +1089,13 @@ public final class StaticFilters { FILTER_PERMANENT_LEGENDARY.setLockedFilter(true); } + public static final FilterCreaturePermanent FILTER_CREATURE_LEGENDARY = new FilterCreaturePermanent(); + + static { + FILTER_CREATURE_LEGENDARY.add(SuperType.LEGENDARY.getPredicate()); + FILTER_CREATURE_LEGENDARY.setLockedFilter(true); + } + public static final FilterCard FILTER_CARD_ARTIFACT_OR_CREATURE = new FilterCard("artifact or creature card"); static {