From 491f47ddc6d3447f9bab888bd3248a9e19b24f9c Mon Sep 17 00:00:00 2001 From: Vivian Greenslade Date: Tue, 22 Aug 2023 20:54:52 -0230 Subject: [PATCH] [WOE] Implement Eriette of the Charmed Apple (#10904) * WIP * implemented can't attack effect * moved logic for "permanents enchanted by Auras" to predicate * added value hint for ability * fixed static properties * changed predicate logic * fixed issues as per PR comments * updated predicate name, changed count from static variable * made DynamicValue static --- .../cards/e/ErietteOfTheCharmedApple.java | 65 +++++++++++++++++++ Mage.Sets/src/mage/sets/WildsOfEldraine.java | 1 + .../EnchantedBySourceControllerPredicate.java | 30 +++++++++ 3 files changed, 96 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/e/ErietteOfTheCharmedApple.java create mode 100644 Mage/src/main/java/mage/filter/predicate/permanent/EnchantedBySourceControllerPredicate.java diff --git a/Mage.Sets/src/mage/cards/e/ErietteOfTheCharmedApple.java b/Mage.Sets/src/mage/cards/e/ErietteOfTheCharmedApple.java new file mode 100644 index 00000000000..e5e8edcd4c6 --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/ErietteOfTheCharmedApple.java @@ -0,0 +1,65 @@ +package mage.cards.e; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.effects.common.GainLifeEffect; +import mage.abilities.effects.common.LoseLifeOpponentsEffect; +import mage.abilities.effects.common.combat.CantAttackYouAllEffect; +import mage.abilities.hint.ValueHint; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.constants.TargetController; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.EnchantedBySourceControllerPredicate; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; + +/** + * + * @author Xanderhall + */ +public final class ErietteOfTheCharmedApple extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures enchanted by an Aura you control"); + private static final DynamicValue count = new PermanentsOnBattlefieldCount(new FilterControlledPermanent(SubType.AURA)); + + static { + filter.add(EnchantedBySourceControllerPredicate.instance); + } + + public ErietteOfTheCharmedApple(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}{B}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.WARLOCK); + this.power = new MageInt(2); + this.toughness = new MageInt(4); + + // Each creature that's enchanted by an Aura you control can't attack you or planeswalkers you control. + this.addAbility(new SimpleStaticAbility(new CantAttackYouAllEffect(Duration.WhileOnBattlefield, filter, true))); + + // At the beginning of your end step, each opponent loses X life and you gain X life, where X is the number of Auras you control. + Ability ability = new BeginningOfEndStepTriggeredAbility(new LoseLifeOpponentsEffect(count), TargetController.YOU, false); + ability.addEffect(new GainLifeEffect(count)); + ability.addHint(new ValueHint("Number of Auras you control", count)); + this.addAbility(ability); + } + + private ErietteOfTheCharmedApple(final ErietteOfTheCharmedApple card) { + super(card); + } + + @Override + public ErietteOfTheCharmedApple copy() { + return new ErietteOfTheCharmedApple(this); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/WildsOfEldraine.java b/Mage.Sets/src/mage/sets/WildsOfEldraine.java index 251dabae304..2e8e2a09172 100644 --- a/Mage.Sets/src/mage/sets/WildsOfEldraine.java +++ b/Mage.Sets/src/mage/sets/WildsOfEldraine.java @@ -53,6 +53,7 @@ public final class WildsOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Edgewall Inn", 255, Rarity.UNCOMMON, mage.cards.e.EdgewallInn.class)); cards.add(new SetCardInfo("Elvish Archivist", 168, Rarity.RARE, mage.cards.e.ElvishArchivist.class)); cards.add(new SetCardInfo("Embereth Veteran", 127, Rarity.UNCOMMON, mage.cards.e.EmberethVeteran.class)); + cards.add(new SetCardInfo("Eriette of the Charmed Apple", 202, Rarity.MYTHIC, mage.cards.e.ErietteOfTheCharmedApple.class)); cards.add(new SetCardInfo("Evolving Wilds", 256, Rarity.COMMON, mage.cards.e.EvolvingWilds.class)); cards.add(new SetCardInfo("Expel the Interlopers", 13, Rarity.RARE, mage.cards.e.ExpelTheInterlopers.class)); cards.add(new SetCardInfo("Faerie Dreamthief", 89, Rarity.UNCOMMON, mage.cards.f.FaerieDreamthief.class)); diff --git a/Mage/src/main/java/mage/filter/predicate/permanent/EnchantedBySourceControllerPredicate.java b/Mage/src/main/java/mage/filter/predicate/permanent/EnchantedBySourceControllerPredicate.java new file mode 100644 index 00000000000..2707e942ab7 --- /dev/null +++ b/Mage/src/main/java/mage/filter/predicate/permanent/EnchantedBySourceControllerPredicate.java @@ -0,0 +1,30 @@ +package mage.filter.predicate.permanent; + +import mage.constants.SubType; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +import java.util.Objects; + +/** + * @author Xanderhall + */ +public enum EnchantedBySourceControllerPredicate implements ObjectSourcePlayerPredicate { +instance; + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + return input.getObject().getAttachments() + .stream() + .map(game::getPermanent) + .filter(Objects::nonNull) + .anyMatch(p -> p.hasSubtype(SubType.AURA, game) && p.isControlledBy(input.getPlayerId())); + } + + @Override + public String toString() { + return "Enchanted by source"; + } +}