From c8445c31a32a09a7554d112f69449a693366efb2 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 16 Aug 2021 09:40:35 -0400 Subject: [PATCH] [AFC] Implemented Immovable Rod --- Mage.Sets/src/mage/cards/i/ImmovableRod.java | 125 ++++++++++++++++++ .../mage/sets/ForgottenRealmsCommander.java | 1 + 2 files changed, 126 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/i/ImmovableRod.java diff --git a/Mage.Sets/src/mage/cards/i/ImmovableRod.java b/Mage.Sets/src/mage/cards/i/ImmovableRod.java new file mode 100644 index 00000000000..d05cf2de318 --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/ImmovableRod.java @@ -0,0 +1,125 @@ +package mage.cards.i; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SkipUntapOptionalAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.RestrictionEffect; +import mage.abilities.effects.keyword.VentureIntoTheDungeonEffect; +import mage.abilities.keyword.InspiredAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterPermanent; +import mage.filter.predicate.mageobject.AnotherPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ImmovableRod extends CardImpl { + + private static final FilterPermanent filter = new FilterPermanent("another permanent"); + + static { + filter.add(AnotherPredicate.instance); + } + + public ImmovableRod(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{W}"); + + // You may choose not to untap Immovable Rod during your untap step. + this.addAbility(new SkipUntapOptionalAbility()); + + // Whenever Immovable Rod becomes untapped, venture into the dungeon. + this.addAbility(new InspiredAbility(new VentureIntoTheDungeonEffect())); + + // {3}{W}, {T}: For as long as Immovable Rod remains tapped, another target permanent loses all abilities and can't attack or block. + Ability ability = new SimpleActivatedAbility(new ImmovableRodAbilityEffect(), new ManaCostsImpl<>("{3}{W}")); + ability.addEffect(new ImmovableRodAttackBlockTargetEffect()); + ability.addCost(new TapSourceCost()); + ability.addTarget(new TargetPermanent(filter)); + this.addAbility(ability); + } + + private ImmovableRod(final ImmovableRod card) { + super(card); + } + + @Override + public ImmovableRod copy() { + return new ImmovableRod(this); + } +} + +class ImmovableRodAbilityEffect extends ContinuousEffectImpl { + + ImmovableRodAbilityEffect() { + super(Duration.Custom, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.Detriment); + staticText = "for as long as {this} remains tapped, another target permanent loses all abilities"; + } + + private ImmovableRodAbilityEffect(final ImmovableRodAbilityEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game); + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (sourcePermanent == null || !sourcePermanent.isTapped() || permanent == null) { + discard(); + return false; + } + permanent.removeAllAbilities(source.getSourceId(), game); + return true; + } + + @Override + public ImmovableRodAbilityEffect copy() { + return new ImmovableRodAbilityEffect(this); + } +} + +class ImmovableRodAttackBlockTargetEffect extends RestrictionEffect { + + ImmovableRodAttackBlockTargetEffect() { + super(Duration.Custom); + staticText = "and can't attack or block"; + } + + public ImmovableRodAttackBlockTargetEffect(final ImmovableRodAttackBlockTargetEffect effect) { + super(effect); + } + + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game); + if (sourcePermanent == null || !sourcePermanent.isTapped()) { + discard(); + return false; + } + return permanent.getId().equals(getTargetPointer().getFirst(game, source)); + } + + @Override + public boolean canAttack(Game game, boolean canUseChooseDialogs) { + return false; + } + + @Override + public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) { + return false; + } + + @Override + public ImmovableRodAttackBlockTargetEffect copy() { + return new ImmovableRodAttackBlockTargetEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java b/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java index dae80c2852a..cd755240846 100644 --- a/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java +++ b/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java @@ -131,6 +131,7 @@ public final class ForgottenRealmsCommander extends ExpansionSet { cards.add(new SetCardInfo("Hostage Taker", 186, Rarity.RARE, mage.cards.h.HostageTaker.class)); cards.add(new SetCardInfo("Hurl Through Hell", 48, Rarity.RARE, mage.cards.h.HurlThroughHell.class)); cards.add(new SetCardInfo("Ignite the Future", 129, Rarity.RARE, mage.cards.i.IgniteTheFuture.class)); + cards.add(new SetCardInfo("Immovable Rod", 7, Rarity.RARE, mage.cards.i.ImmovableRod.class)); cards.add(new SetCardInfo("Imprisoned in the Moon", 85, Rarity.RARE, mage.cards.i.ImprisonedInTheMoon.class)); cards.add(new SetCardInfo("Indomitable Might", 40, Rarity.RARE, mage.cards.i.IndomitableMight.class)); cards.add(new SetCardInfo("Izzet Chemister", 130, Rarity.RARE, mage.cards.i.IzzetChemister.class));