Search in sources :

Example 1 with AddCountersAttachedEffect

use of mage.abilities.effects.common.counter.AddCountersAttachedEffect in project mage by magefree.

the class ConsumingFerocityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(source.getFirstTarget());
    if (creature != null) {
        Effect effect = new AddCountersAttachedEffect(CounterType.P1P0.createInstance(), "enchanted creature");
        effect.apply(game, source);
        if (creature.getCounters(game).getCount(CounterType.P1P0) > 2) {
            Player player = game.getPlayer(creature.getControllerId());
            if (player != null) {
                player.damage(creature.getPower().getValue(), creature.getId(), source, game);
            }
            effect = new DestroyTargetEffect(true);
            effect.setTargetPointer(new FixedTarget(creature, game));
            effect.apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AddCountersAttachedEffect(mage.abilities.effects.common.counter.AddCountersAttachedEffect) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) AddCountersAttachedEffect(mage.abilities.effects.common.counter.AddCountersAttachedEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) BoostEnchantedEffect(mage.abilities.effects.common.continuous.BoostEnchantedEffect)

Aggregations

Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 AttachEffect (mage.abilities.effects.common.AttachEffect)1 DestroyTargetEffect (mage.abilities.effects.common.DestroyTargetEffect)1 BoostEnchantedEffect (mage.abilities.effects.common.continuous.BoostEnchantedEffect)1 AddCountersAttachedEffect (mage.abilities.effects.common.counter.AddCountersAttachedEffect)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 TargetPermanent (mage.target.TargetPermanent)1 FixedTarget (mage.target.targetpointer.FixedTarget)1