foul-magics/Mage/src/main/java/mage/abilities/common/AuraAttachedTriggeredAbility.java
Evan Kranzler ca80806400
Reworking triggered ability text generation to allow for ability words and flavor words to be added more easily (#8010)
* 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
2021-07-15 07:46:38 -04:00

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);
}
}