mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 13:32:06 -08:00
updated AttacksOrBlocksAttachedTriggeredAbility
This commit is contained in:
parent
13949d8e3e
commit
2db0da8429
9 changed files with 71 additions and 82 deletions
|
|
@ -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, ";
|
||||
}
|
||||
}
|
||||
|
|
@ -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, ";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue