Search in sources :

Example 1 with BlockingAttackerIdPredicate

use of mage.filter.predicate.permanent.BlockingAttackerIdPredicate in project mage by magefree.

the class LabyrinthRaptorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (permanent == null) {
        return false;
    }
    Player player = game.getPlayer(game.getCombat().getDefendingPlayerId(permanent.getId(), game));
    if (player == null) {
        return false;
    }
    FilterPermanent filterPermanent = new FilterPermanent("creature blocking " + permanent.getIdName());
    filterPermanent.add(new BlockingAttackerIdPredicate(permanent.getId()));
    Effect effect = new SacrificeEffect(filterPermanent, 1, "");
    effect.setTargetPointer(new FixedTarget(player.getId(), game));
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) BlockingAttackerIdPredicate(mage.filter.predicate.permanent.BlockingAttackerIdPredicate) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) Effect(mage.abilities.effects.Effect) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect)

Example 2 with BlockingAttackerIdPredicate

use of mage.filter.predicate.permanent.BlockingAttackerIdPredicate in project mage by magefree.

the class PlagueWightEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent == null) {
        return false;
    }
    FilterCreaturePermanent filter = new FilterCreaturePermanent();
    filter.add(new BlockingAttackerIdPredicate(source.getSourceId()));
    game.addEffect(new BoostAllEffect(-1, -1, Duration.EndOfTurn, filter, false), source);
    return true;
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) BlockingAttackerIdPredicate(mage.filter.predicate.permanent.BlockingAttackerIdPredicate) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect)

Example 3 with BlockingAttackerIdPredicate

use of mage.filter.predicate.permanent.BlockingAttackerIdPredicate in project mage by magefree.

the class GreaterWerewolfEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (sourcePermanent != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(Predicates.or(new BlockedByIdPredicate(sourcePermanent.getId()), new BlockingAttackerIdPredicate(sourcePermanent.getId())));
        for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
            Effect effect = new AddCountersTargetEffect(CounterType.M0M2.createInstance(), Outcome.UnboostCreature);
            effect.setTargetPointer(new FixedTarget(permanent, game));
            effect.apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) BlockingAttackerIdPredicate(mage.filter.predicate.permanent.BlockingAttackerIdPredicate) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) BlockedByIdPredicate(mage.filter.predicate.permanent.BlockedByIdPredicate)

Example 4 with BlockingAttackerIdPredicate

use of mage.filter.predicate.permanent.BlockingAttackerIdPredicate in project mage by magefree.

the class SpittingSlugEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (sourcePermanent != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(Predicates.or(new BlockedByIdPredicate(sourcePermanent.getId()), new BlockingAttackerIdPredicate(sourcePermanent.getId())));
        for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
            ContinuousEffect effect = new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(permanent, game));
            game.addEffect(effect, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) BlockingAttackerIdPredicate(mage.filter.predicate.permanent.BlockingAttackerIdPredicate) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) BlockedByIdPredicate(mage.filter.predicate.permanent.BlockedByIdPredicate)

Aggregations

FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)4 BlockingAttackerIdPredicate (mage.filter.predicate.permanent.BlockingAttackerIdPredicate)4 Permanent (mage.game.permanent.Permanent)4 FixedTarget (mage.target.targetpointer.FixedTarget)3 Effect (mage.abilities.effects.Effect)2 OneShotEffect (mage.abilities.effects.OneShotEffect)2 BoostAllEffect (mage.abilities.effects.common.continuous.BoostAllEffect)2 BlockedByIdPredicate (mage.filter.predicate.permanent.BlockedByIdPredicate)2 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 SacrificeEffect (mage.abilities.effects.common.SacrificeEffect)1 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)1 AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)1 FilterPermanent (mage.filter.FilterPermanent)1 Player (mage.players.Player)1