Search in sources :

Example 6 with PreventDamageToTargetEffect

use of mage.abilities.effects.common.PreventDamageToTargetEffect in project mage by magefree.

the class SamiteCenserBearerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        PreventDamageToTargetEffect effect = new PreventDamageToTargetEffect(Duration.EndOfTurn, 1);
        List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game);
        for (Permanent permanent : permanents) {
            effect.setTargetPointer(new FixedTarget(permanent, game));
            game.addEffect(effect, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) PreventDamageToTargetEffect(mage.abilities.effects.common.PreventDamageToTargetEffect)

Aggregations

PreventDamageToTargetEffect (mage.abilities.effects.common.PreventDamageToTargetEffect)6 Permanent (mage.game.permanent.Permanent)6 Player (mage.players.Player)5 FixedTarget (mage.target.targetpointer.FixedTarget)5 ContinuousEffect (mage.abilities.effects.ContinuousEffect)2 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)2 UUID (java.util.UUID)1 ObjectColor (mage.ObjectColor)1 SpecialAction (mage.abilities.SpecialAction)1 CreateDelayedTriggeredAbilityEffect (mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect)1 CreateSpecialActionEffect (mage.abilities.effects.common.CreateSpecialActionEffect)1 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)1 TargetPermanent (mage.target.TargetPermanent)1