foul-magics/Mage/src/main/java/mage/abilities/common/UnattachedTriggeredAbility.java

47 lines
1.2 KiB
Java

package mage.abilities.common;
import mage.constants.Zone;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author nantuko
*/
public class UnattachedTriggeredAbility extends TriggeredAbilityImpl {
public UnattachedTriggeredAbility(Effect effect, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
setTriggerPhrase("Whenever {this} becomes unattached from a permanent, ");
}
public UnattachedTriggeredAbility(final UnattachedTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.UNATTACHED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.getSourceId()) ) {
getEffects().get(0).setTargetPointer(new FixedTarget(event.getTargetId(), game));
return true;
}
return false;
}
@Override
public UnattachedTriggeredAbility copy() {
return new UnattachedTriggeredAbility(this);
}
}