[LTR] Implement Bewitching Leechcraft (#10615)

This commit is contained in:
Susucre 2023-07-15 03:31:34 +02:00 committed by GitHub
parent 72ebe2b1f1
commit 189dff86ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 107 additions and 0 deletions

View file

@ -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());
}
}

View file

@ -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));