From 189dff86ea78edf273ebf6e72ed0dad8b4798f64 Mon Sep 17 00:00:00 2001 From: Susucre <34709007+Susucre@users.noreply.github.com> Date: Sat, 15 Jul 2023 03:31:34 +0200 Subject: [PATCH] [LTR] Implement Bewitching Leechcraft (#10615) --- .../mage/cards/b/BewitchingLeechcraft.java | 106 ++++++++++++++++++ .../TheLordOfTheRingsTalesOfMiddleEarth.java | 1 + 2 files changed, 107 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/b/BewitchingLeechcraft.java diff --git a/Mage.Sets/src/mage/cards/b/BewitchingLeechcraft.java b/Mage.Sets/src/mage/cards/b/BewitchingLeechcraft.java new file mode 100644 index 00000000000..66046327158 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BewitchingLeechcraft.java @@ -0,0 +1,106 @@ +package mage.cards.b; + +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.TapEnchantedEffect; +import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; + +/** + * + * @author Susucr + */ +public final class BewitchingLeechcraft extends CardImpl { + + public BewitchingLeechcraft(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}"); + + this.subtype.add(SubType.AURA); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.Tap)); + this.addAbility(new EnchantAbility(auraTarget)); + + // When Bewitching Leechcraft enters the battlefield, tap enchanted creature. + this.addAbility(new EntersBattlefieldTriggeredAbility(new TapEnchantedEffect())); + + // Enchanted creature has "If this creature would untap during your untap step, remove a +1/+1 counter from it instead. If you do, untap it." + this.addAbility(new SimpleStaticAbility( + new GainAbilityAttachedEffect( + new SimpleStaticAbility(new BewitchingLeechcraftReplacementEffect()), + AttachmentType.AURA + ) + )); + } + + private BewitchingLeechcraft(final BewitchingLeechcraft card) { + super(card); + } + + @Override + public BewitchingLeechcraft copy() { + return new BewitchingLeechcraft(this); + } +} + +class BewitchingLeechcraftReplacementEffect extends ReplacementEffectImpl { + + BewitchingLeechcraftReplacementEffect() { + super(Duration.EndOfGame, Outcome.Detriment); + staticText = "If this creature would untap during your untap step, " + + "remove a +1/+1 counter from it instead. If you do, untap it."; + } + + private BewitchingLeechcraftReplacementEffect(final BewitchingLeechcraftReplacementEffect effect) { + super(effect); + } + + @Override + public BewitchingLeechcraftReplacementEffect copy() { + return new BewitchingLeechcraftReplacementEffect(this); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.UNTAP; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Permanent permanentUntapping = game.getPermanent(source.getSourceId()); + if(!applies(event,source,game)){ + return false; + } + + // If we could not remove a counter, we are replacing the UNTAP event. + // If we could remove a counter, we are not replacing the UNTAP, just adding to it. + return !permanentUntapping.getCounters(game).removeCounter(CounterType.P1P1, 1); + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return game.getTurnStepType() == PhaseStep.UNTAP + && event.getTargetId().equals(source.getSourceId()); + } +} diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java index fda4a30d30d..72ac12d8922 100644 --- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java +++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java @@ -31,6 +31,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet { cards.add(new SetCardInfo("Barad-dur", 253, Rarity.RARE, mage.cards.b.BaradDur.class)); cards.add(new SetCardInfo("Barrow-Blade", 237, Rarity.UNCOMMON, mage.cards.b.BarrowBlade.class)); cards.add(new SetCardInfo("Battle-Scarred Goblin", 115, Rarity.COMMON, mage.cards.b.BattleScarredGoblin.class)); + cards.add(new SetCardInfo("Bewitching Leechcraft", 41, Rarity.COMMON, mage.cards.b.BewitchingLeechcraft.class)); cards.add(new SetCardInfo("Bilbo's Ring", 298, Rarity.RARE, mage.cards.b.BilbosRing.class)); cards.add(new SetCardInfo("Bilbo, Retired Burglar", 196, Rarity.UNCOMMON, mage.cards.b.BilboRetiredBurglar.class)); cards.add(new SetCardInfo("Bill Ferny, Bree Swindler", 42, Rarity.UNCOMMON, mage.cards.b.BillFernyBreeSwindler.class));