updated AttacksOrBlocksAttachedTriggeredAbility

This commit is contained in:
Evan Kranzler 2021-08-22 18:08:40 -04:00
parent 13949d8e3e
commit 2db0da8429
9 changed files with 71 additions and 82 deletions

View file

@ -3,16 +3,13 @@ package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.AttacksOrBlocksEnchantedTriggeredAbility;
import mage.abilities.common.AttacksOrBlocksAttachedTriggeredAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.LoseLifeControllerAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.*;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -34,7 +31,7 @@ public final class ContaminatedBond extends CardImpl {
this.addAbility(ability);
// Whenever enchanted creature attacks or blocks, its controller loses 3 life.
this.addAbility(new AttacksOrBlocksEnchantedTriggeredAbility(Zone.BATTLEFIELD, new LoseLifeControllerAttachedEffect(3)));
this.addAbility(new AttacksOrBlocksAttachedTriggeredAbility(new LoseLifeControllerAttachedEffect(3), AttachmentType.AURA));
}
private ContaminatedBond(final ContaminatedBond card) {

View file

@ -1,24 +1,22 @@
package mage.cards.c;
import java.util.UUID;
import mage.constants.SubType;
import mage.constants.*;
import mage.target.common.TargetCreaturePermanent;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.AttacksOrBlocksEnchantedTriggeredAbility;
import mage.abilities.common.AttacksOrBlocksAttachedTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -44,8 +42,8 @@ public final class Cunning extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(3, 3)));
// When enchanted creature attacks or blocks, sacrifice Cunning at the beginning of the next cleanup step.
this.addAbility(new AttacksOrBlocksEnchantedTriggeredAbility(Zone.BATTLEFIELD,
new SacrificeSourceBeginningCleanupStepEffect()));
this.addAbility(new AttacksOrBlocksAttachedTriggeredAbility(
new SacrificeSourceBeginningCleanupStepEffect(), AttachmentType.AURA));
}
private Cunning(final Cunning card) {

View file

@ -5,7 +5,7 @@ import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.AttacksOrBlocksEnchantedTriggeredAbility;
import mage.abilities.common.AttacksOrBlocksAttachedTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
@ -18,10 +18,7 @@ import mage.abilities.keyword.EnchantAbility;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent;
@ -53,7 +50,7 @@ public final class Imprison extends CardImpl {
this.addAbility(new ImprisonTriggeredAbility());
// Whenever enchanted creature attacks or blocks, you may pay {1}. If you do, tap the creature, remove it from combat, and creatures it was blocking that had become blocked by only that creature this combat become unblocked. If you don't, destroy Imprison.
this.addAbility(new AttacksOrBlocksEnchantedTriggeredAbility(Zone.BATTLEFIELD, new DoIfCostPaid(new ImprisonUnblockEffect(), new DestroySourceEffect(), new ManaCostsImpl("1"))));
this.addAbility(new AttacksOrBlocksAttachedTriggeredAbility(new DoIfCostPaid(new ImprisonUnblockEffect(), new DestroySourceEffect(), new ManaCostsImpl("1")), AttachmentType.AURA));
}
private Imprison(final Imprison card) {

View file

@ -3,16 +3,13 @@ package mage.cards.l;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.AttacksOrBlocksEnchantedTriggeredAbility;
import mage.abilities.common.AttacksOrBlocksAttachedTriggeredAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.*;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -35,7 +32,7 @@ public final class LuminousWake extends CardImpl {
this.addAbility(ability);
// Whenever enchanted creature attacks or blocks, you gain 4 life.
Ability ability2 = new AttacksOrBlocksEnchantedTriggeredAbility(Zone.BATTLEFIELD, new GainLifeEffect(4));
Ability ability2 = new AttacksOrBlocksAttachedTriggeredAbility(new GainLifeEffect(4), AttachmentType.AURA);
this.addAbility(ability2);
}

View file

@ -2,7 +2,7 @@ package mage.cards.n;
import java.util.UUID;
import mage.abilities.common.AttacksOrBlocksEnchantedTriggeredAbility;
import mage.abilities.common.AttacksOrBlocksAttachedTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.LoseLifeControllerAttachedEffect;
@ -35,7 +35,7 @@ public final class NettlingCurse extends CardImpl {
this.addAbility(ability);
// Whenever enchanted creature attacks or blocks, its controller loses 3 life.
this.addAbility(new AttacksOrBlocksEnchantedTriggeredAbility(Zone.BATTLEFIELD, new LoseLifeControllerAttachedEffect(3)));
this.addAbility(new AttacksOrBlocksAttachedTriggeredAbility(new LoseLifeControllerAttachedEffect(3), AttachmentType.AURA));
// {1}{R}: Enchanted creature attacks this turn if able.
this.addAbility(new SimpleActivatedAbility(new AttacksIfAbleAttachedEffect(Duration.EndOfTurn, AttachmentType.AURA).setText("Enchanted creature attacks this turn if able."), new ManaCostsImpl("{1}{R}")));

View file

@ -3,16 +3,13 @@ package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.AttacksOrBlocksEnchantedTriggeredAbility;
import mage.abilities.common.AttacksOrBlocksAttachedTriggeredAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.LoseLifeControllerAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.*;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -37,7 +34,7 @@ public final class SinisterPossession extends CardImpl {
this.addAbility(ability);
// Whenever enchanted creature attacks or blocks, it's controller loses 2 life.
this.addAbility(new AttacksOrBlocksEnchantedTriggeredAbility(Zone.BATTLEFIELD, new LoseLifeControllerAttachedEffect(2)));
this.addAbility(new AttacksOrBlocksAttachedTriggeredAbility(new LoseLifeControllerAttachedEffect(2), AttachmentType.AURA));
}
private SinisterPossession(final SinisterPossession card) {

View file

@ -1,7 +1,7 @@
package mage.cards.w;
import mage.abilities.Ability;
import mage.abilities.common.AttacksOrBlocksEnchantedTriggeredAbility;
import mage.abilities.common.AttacksOrBlocksAttachedTriggeredAbility;
import mage.abilities.common.DealsDamageToAPlayerAttachedTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
@ -37,12 +37,9 @@ public final class WandOfOrcus extends CardImpl {
// Whenever equipped creature attacks or blocks, it and Zombies you control gain
// deathtouch until end of turn.
Ability deathTouchAbility = new AttacksOrBlocksEnchantedTriggeredAbility(
Zone.BATTLEFIELD,
new GainAbilityAttachedEffect(
DeathtouchAbility.getInstance(), AttachmentType.EQUIPMENT, Duration.EndOfTurn
).setText("it")
);
Ability deathTouchAbility = new AttacksOrBlocksAttachedTriggeredAbility(new GainAbilityAttachedEffect(
DeathtouchAbility.getInstance(), AttachmentType.EQUIPMENT, Duration.EndOfTurn
).setText("it"), AttachmentType.EQUIPMENT);
deathTouchAbility.addEffect(new GainAbilityControlledEffect(
DeathtouchAbility.getInstance(), Duration.EndOfTurn, filter
).concatBy("and"));

View file

@ -0,0 +1,48 @@
// @author jeffwadsworth
package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.AttachmentType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
public class AttacksOrBlocksAttachedTriggeredAbility extends TriggeredAbilityImpl {
private final AttachmentType attachmentType;
public AttacksOrBlocksAttachedTriggeredAbility(Effect effect, AttachmentType attachmentType) {
super(Zone.BATTLEFIELD, effect);
this.attachmentType = attachmentType;
}
public AttacksOrBlocksAttachedTriggeredAbility(final AttacksOrBlocksAttachedTriggeredAbility ability) {
super(ability);
this.attachmentType = ability.attachmentType;
}
@Override
public AttacksOrBlocksAttachedTriggeredAbility copy() {
return new AttacksOrBlocksAttachedTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ATTACKER_DECLARED
|| event.getType() == GameEvent.EventType.BLOCKER_DECLARED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = getSourcePermanentOrLKI(game);
return enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo());
}
@Override
public String getTriggerPhrase() {
return "Whenever " + attachmentType.verb().toLowerCase() + " creature attacks or blocks, ";
}
}

View file

@ -1,42 +0,0 @@
// @author jeffwadsworth
package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
public class AttacksOrBlocksEnchantedTriggeredAbility extends TriggeredAbilityImpl {
public AttacksOrBlocksEnchantedTriggeredAbility(Zone zone, Effect effect) {
super(zone, effect);
}
public AttacksOrBlocksEnchantedTriggeredAbility(final AttacksOrBlocksEnchantedTriggeredAbility ability) {
super(ability);
}
@Override
public AttacksOrBlocksEnchantedTriggeredAbility copy() {
return new AttacksOrBlocksEnchantedTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ATTACKER_DECLARED || event.getType() == GameEvent.EventType.BLOCKER_DECLARED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanent(this.getSourceId());
return enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo());
}
@Override
public String getTriggerPhrase() {
return "Whenever enchanted creature attacks or blocks, ";
}
}