fix Realmbreaker's Grasp

This commit is contained in:
xenohedron 2024-06-12 20:42:24 -04:00
parent fb051a70b5
commit 33346fa118

View file

@ -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> ability = game.getAbility(event.getTargetId(), event.getSourceId());
return ability.isPresent() && ability.get().isNonManaActivatedAbility();
}
return false;
}
}