From 33346fa118e70e7f0b9630b61368f15e5304d2c5 Mon Sep 17 00:00:00 2001 From: xenohedron Date: Wed, 12 Jun 2024 20:42:24 -0400 Subject: [PATCH] fix Realmbreaker's Grasp --- .../src/mage/cards/r/RealmbreakersGrasp.java | 50 +++++++++++++++++-- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/Mage.Sets/src/mage/cards/r/RealmbreakersGrasp.java b/Mage.Sets/src/mage/cards/r/RealmbreakersGrasp.java index 11a5435dee7..f4145c273e6 100644 --- a/Mage.Sets/src/mage/cards/r/RealmbreakersGrasp.java +++ b/Mage.Sets/src/mage/cards/r/RealmbreakersGrasp.java @@ -1,17 +1,21 @@ package mage.cards.r; +import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.common.AttachEffect; -import mage.abilities.effects.common.combat.CantBlockAttackActivateAttachedEffect; +import mage.abilities.effects.common.combat.CantAttackBlockAttachedEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.SubType; +import mage.constants.*; import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; import mage.target.TargetPermanent; +import java.util.Optional; import java.util.UUID; /** @@ -31,7 +35,10 @@ public final class RealmbreakersGrasp extends CardImpl { this.addAbility(new EnchantAbility(auraTarget)); // Enchanted permanent can't attack or block, and its activated abilities can't be activated unless they're mana abilities. - this.addAbility(new SimpleStaticAbility(new CantBlockAttackActivateAttachedEffect("permanent"))); + Ability ability = new SimpleStaticAbility(new CantAttackBlockAttachedEffect(AttachmentType.AURA) + .setText("Enchanted permanent can't attack or block,")); + ability.addEffect(new RealmbreakersGraspEffect()); + this.addAbility(ability); } private RealmbreakersGrasp(final RealmbreakersGrasp card) { @@ -43,3 +50,36 @@ public final class RealmbreakersGrasp extends CardImpl { return new RealmbreakersGrasp(this); } } + +class RealmbreakersGraspEffect extends ContinuousRuleModifyingEffectImpl { + + RealmbreakersGraspEffect() { + super(Duration.WhileOnBattlefield, Outcome.Detriment); + staticText = "and its activated abilities can't be activated unless they're mana abilities"; + } + + private RealmbreakersGraspEffect(final RealmbreakersGraspEffect effect) { + super(effect); + } + + @Override + public RealmbreakersGraspEffect copy() { + return new RealmbreakersGraspEffect(this); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ACTIVATE_ABILITY; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + Permanent enchantment = game.getPermanent(source.getSourceId()); + if (enchantment != null && enchantment.isAttachedTo(event.getSourceId())) { + Optional ability = game.getAbility(event.getTargetId(), event.getSourceId()); + return ability.isPresent() && ability.get().isNonManaActivatedAbility(); + + } + return false; + } +}