Search in sources :

Example 31 with AddCountersTargetEffect

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

the class ReyhanLastOfTheAbzanTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zcEvent = (ZoneChangeEvent) event;
    // Dies or is put in the command zone
    if (zcEvent.getFromZone() != Zone.BATTLEFIELD) {
        return false;
    }
    if (zcEvent.getToZone() != Zone.GRAVEYARD && zcEvent.getToZone() != Zone.COMMAND) {
        return false;
    }
    // A creature
    Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
    if (permanent == null || !permanent.isCreature(game)) {
        return false;
    }
    // You control
    Player player = game.getPlayer(this.getControllerId());
    if (player == null || !permanent.isControlledBy(getControllerId())) {
        return false;
    }
    // If it had one or more +1/+1 counters on it
    int countersOn = permanent.getCounters(game).getCount(CounterType.P1P1);
    if (countersOn == 0) {
        return false;
    }
    // You may put that may +1/+1 counters on target creature
    this.getEffects().clear();
    this.addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance(countersOn)));
    return true;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 32 with AddCountersTargetEffect

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

the class StensiaMasqueradeTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent permanent = game.getPermanent(event.getSourceId());
    if (damageEvent.isCombatDamage() && permanent != null && permanent.hasSubtype(SubType.VAMPIRE, game) && permanent.isControlledBy(controllerId)) {
        this.getEffects().clear();
        AddCountersTargetEffect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
        effect.setTargetPointer(new FixedTarget(permanent, game));
        this.addEffect(effect);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 33 with AddCountersTargetEffect

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

the class CocoonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (permanent != null) {
        int amount = permanent.getCounters(game).getCount(CounterType.PUPA);
        if (amount > 0) {
            permanent.removeCounters(CounterType.PUPA.createInstance(), source, game);
        } else {
            Permanent enchantedPermanent = game.getPermanent(permanent.getAttachedTo());
            permanent.sacrifice(source, game);
            if (enchantedPermanent != null) {
                Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
                effect.setTargetPointer(new FixedTarget(enchantedPermanent, game));
                effect.apply(game, source);
                ContinuousEffect effect2 = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.Custom);
                effect2.setTargetPointer(new FixedTarget(enchantedPermanent, game));
                game.addEffect(effect2, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) AttachEffect(mage.abilities.effects.common.AttachEffect) ConditionalContinuousRuleModifyingEffect(mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect) TapEnchantedEffect(mage.abilities.effects.common.TapEnchantedEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) DontUntapInControllersUntapStepEnchantedEffect(mage.abilities.effects.common.DontUntapInControllersUntapStepEnchantedEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 34 with AddCountersTargetEffect

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

the class BiogenicUpgradeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (UUID permanentId : source.getTargets().get(0).getTargets()) {
        Permanent permanent = game.getPermanent(permanentId);
        if (permanent == null) {
            continue;
        }
        Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(permanent.getCounters(game).getCount(CounterType.P1P1)));
        effect.setTargetPointer(new FixedTarget(permanent, game));
        effect.apply(game, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) DistributeCountersEffect(mage.abilities.effects.common.counter.DistributeCountersEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 35 with AddCountersTargetEffect

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

the class DecimatorBeetleEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (targetCreature != null && targetCreature.getCounters(game).containsKey(CounterType.M1M1)) {
        Effect effect = new RemoveCounterTargetEffect(CounterType.M1M1.createInstance(1));
        effect.setTargetPointer(targetPointer);
        effect.apply(game, source);
    }
    targetCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
    if (targetCreature != null) {
        Effect effect = new AddCountersTargetEffect(CounterType.M1M1.createInstance(1));
        effect.setTargetPointer(new FixedTarget(source.getTargets().get(1).getFirstTarget(), game));
        effect.apply(game, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) RemoveCounterTargetEffect(mage.abilities.effects.common.counter.RemoveCounterTargetEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) RemoveCounterTargetEffect(mage.abilities.effects.common.counter.RemoveCounterTargetEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Aggregations

AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)36 FixedTarget (mage.target.targetpointer.FixedTarget)27 Permanent (mage.game.permanent.Permanent)24 Effect (mage.abilities.effects.Effect)21 OneShotEffect (mage.abilities.effects.OneShotEffect)18 Player (mage.players.Player)18 Card (mage.cards.Card)7 UUID (java.util.UUID)6 ContinuousEffect (mage.abilities.effects.ContinuousEffect)6 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)6 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)6 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)6 Target (mage.target.Target)5 TargetPermanent (mage.target.TargetPermanent)5 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)4 Ability (mage.abilities.Ability)3 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)3 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)3 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)3 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)3