Search in sources :

Example 1 with BecomesTargetTriggeredAbility

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;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) BecomesTargetTriggeredAbility(mage.abilities.common.BecomesTargetTriggeredAbility) Player(mage.players.Player) FilterSpell(mage.filter.FilterSpell) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ScryEffect(mage.abilities.effects.keyword.ScryEffect) Effect(mage.abilities.effects.Effect) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect) TriggeredAbility(mage.abilities.TriggeredAbility) BecomesTargetTriggeredAbility(mage.abilities.common.BecomesTargetTriggeredAbility) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect)

Aggregations

TriggeredAbility (mage.abilities.TriggeredAbility)1 BecomesTargetTriggeredAbility (mage.abilities.common.BecomesTargetTriggeredAbility)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)1 SacrificeSourceEffect (mage.abilities.effects.common.SacrificeSourceEffect)1 ScryEffect (mage.abilities.effects.keyword.ScryEffect)1 FilterSpell (mage.filter.FilterSpell)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)1 FixedTarget (mage.target.targetpointer.FixedTarget)1