Search in sources :

Example 1 with FilterSpell

use of mage.filter.FilterSpell in project mage by magefree.

the class ParadisePlumeSpellCastTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ObjectColor color = (ObjectColor) game.getState().getValue(getSourceId() + "_color");
    if (color != null) {
        FilterSpell filter = new FilterSpell();
        filter.add(new ColorPredicate(color));
        Spell spell = game.getStack().getSpell(event.getTargetId());
        return (spell != null && filter.match(spell, getSourceId(), getControllerId(), game));
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterSpell(mage.filter.FilterSpell) ObjectColor(mage.ObjectColor) FilterSpell(mage.filter.FilterSpell) Spell(mage.game.stack.Spell)

Example 2 with FilterSpell

use of mage.filter.FilterSpell 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)

Example 3 with FilterSpell

use of mage.filter.FilterSpell in project mage by magefree.

the class CantBeTargetedAllEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    Permanent permanent = game.getPermanent(event.getTargetId());
    if (permanent != null && filterTarget.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
        StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
        MageObject sourceObject;
        if (stackObject instanceof StackAbility) {
            if (filterSource instanceof FilterSpell) {
                // only spells have to be selected
                return false;
            }
            sourceObject = ((StackAbility) stackObject).getSourceObject(game);
        } else {
            sourceObject = stackObject;
        }
        if (filterSource.match(sourceObject, game)) {
            return true;
        }
    }
    return false;
}
Also used : FilterSpell(mage.filter.FilterSpell) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) StackObject(mage.game.stack.StackObject) MageObject(mage.MageObject) StackAbility(mage.game.stack.StackAbility)

Aggregations

FilterSpell (mage.filter.FilterSpell)3 Permanent (mage.game.permanent.Permanent)2 MageObject (mage.MageObject)1 ObjectColor (mage.ObjectColor)1 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 FilterPermanent (mage.filter.FilterPermanent)1 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)1 Spell (mage.game.stack.Spell)1 StackAbility (mage.game.stack.StackAbility)1 StackObject (mage.game.stack.StackObject)1 Player (mage.players.Player)1 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)1 FixedTarget (mage.target.targetpointer.FixedTarget)1