forked from External/mage
* refactor all instances of getRule in triggered abilities using new getTriggerPrefix method * updated triggered ability rules generation * renamed method * fixed a test failure * some more refactoring * simplified some instances of ability word usage
52 lines
1.4 KiB
Java
52 lines
1.4 KiB
Java
|
|
package mage.abilities.common;
|
|
|
|
import mage.abilities.TriggeredAbilityImpl;
|
|
import mage.abilities.effects.Effect;
|
|
import mage.constants.SubType;
|
|
import mage.constants.Zone;
|
|
import mage.game.Game;
|
|
import mage.game.events.GameEvent;
|
|
import mage.game.permanent.Permanent;
|
|
|
|
/**
|
|
*
|
|
* @author LevelX2
|
|
*/
|
|
public class AuraAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|
|
|
public AuraAttachedTriggeredAbility(Effect effect, boolean optional) {
|
|
super(Zone.BATTLEFIELD, effect, optional);
|
|
}
|
|
|
|
public AuraAttachedTriggeredAbility(final AuraAttachedTriggeredAbility ability) {
|
|
super(ability);
|
|
}
|
|
|
|
@Override
|
|
public boolean checkEventType(GameEvent event, Game game) {
|
|
return event.getType() == GameEvent.EventType.ATTACHED;
|
|
}
|
|
|
|
@Override
|
|
public boolean checkTrigger(GameEvent event, Game game) {
|
|
if (event.getTargetId().equals(this.getSourceId())) {
|
|
Permanent attachment = game.getPermanent(event.getSourceId());
|
|
if (attachment != null && attachment.hasSubtype(SubType.AURA, game)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public String getTriggerPhrase() {
|
|
return "Whenever an Aura becomes attached to {this}, " ;
|
|
}
|
|
|
|
@Override
|
|
public AuraAttachedTriggeredAbility copy() {
|
|
return new AuraAttachedTriggeredAbility(this);
|
|
}
|
|
|
|
}
|