use of mage.abilities.common.BecomesTargetTriggeredAbility in project mage by magefree.
the class ForceProjectionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (controller != null && permanent != null) {
// Create a token that is a copy of target creature
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
effect.setTargetPointer(new FixedTarget(permanent, game));
// except that it is an Illusion in addition to its other types
effect.setAdditionalSubType(SubType.SPIRIT);
effect.apply(game, source);
// and gains "When this creature becomes the target of a spell, sacrifice it."
Effect sacrificeEffect = new SacrificeSourceEffect();
sacrificeEffect.setTargetPointer(new FixedTarget(effect.getAddedPermanents().get(0), game));
TriggeredAbility ability = new BecomesTargetTriggeredAbility(sacrificeEffect, new FilterSpell());
game.addTriggeredAbility(ability, null);
return true;
}
return false;
}
Aggregations