Search in sources :

Example 6 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class PrimalAdversaryToken method apply.

@Override
public boolean apply(Game game, Ability source) {
    Integer timesPaid = (Integer) getValue("timesPaid");
    if (timesPaid == null || timesPaid <= 0) {
        return false;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(timesPaid)), false, staticText);
    ability.addEffect(new BecomesCreatureTargetEffect(new PrimalAdversaryToken(), false, true, Duration.Custom));
    ability.addTarget(new TargetPermanent(0, timesPaid, StaticFilters.FILTER_CONTROLLED_PERMANENT_LANDS));
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) BecomesCreatureTargetEffect(mage.abilities.effects.common.continuous.BecomesCreatureTargetEffect) TargetPermanent(mage.target.TargetPermanent)

Example 7 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class SpareDaggerEffect method makeAbility.

@Override
protected Ability makeAbility(Game game, Ability source) {
    if (source == null || game == null) {
        return null;
    }
    String sourceName = source.getSourcePermanentIfItStillExists(game).getName();
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(1), false, "This creature deals 1 damage to any target");
    ability.addTarget(new TargetAnyTarget());
    return new AttacksTriggeredAbility(new DoWhenCostPaid(ability, useAttachedCost.copy().setMageObjectReference(source, game), "Sacrifice " + sourceName + "?"), false, "Whenever this creature attacks, you may sacrifice " + sourceName + ". When you do, this creature deals 1 damage to any target.");
}
Also used : DoWhenCostPaid(mage.abilities.effects.common.DoWhenCostPaid) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) AttacksTriggeredAbility(mage.abilities.common.AttacksTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 8 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class TaintedAdversaryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Integer timesPaid = (Integer) getValue("timesPaid");
    if (timesPaid == null || timesPaid <= 0) {
        return false;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(timesPaid)), false, staticText);
    ability.addEffect(new CreateTokenEffect(new ZombieDecayedToken(), 2 * timesPaid));
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) ZombieDecayedToken(mage.game.permanent.token.ZombieDecayedToken)

Example 9 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class LeylineTyrantDamageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
    String manaString;
    if (costX == 0) {
        manaString = "{0}";
    } else {
        manaString = "";
        for (int i = 0; i < costX; i++) {
            manaString += "{R}";
        }
    }
    Cost cost = new ManaCostsImpl<>(manaString);
    cost.clearPaid();
    if (!cost.pay(source, game, source, source.getControllerId(), false)) {
        return false;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(costX), false, "{this} deals " + costX + " damage to any target");
    ability.addTarget(new TargetAnyTarget());
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : Player(mage.players.Player) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 10 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class MagmaPummelerEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    int damage = event.getAmount();
    preventDamageAction(event, source, game);
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent == null) {
        return false;
    }
    int beforeCounters = permanent.getCounters(game).getCount(CounterType.P1P1);
    permanent.removeCounters(CounterType.P1P1.createInstance(damage), source, game);
    int countersRemoved = beforeCounters - permanent.getCounters(game).getCount(CounterType.P1P1);
    if (countersRemoved > 0) {
        ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(countersRemoved), false, "{this} deals that much damage to any target");
        ability.addTarget(new TargetAnyTarget());
        game.fireReflexiveTriggeredAbility(ability, source);
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Aggregations

ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)37 Player (mage.players.Player)23 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)15 Permanent (mage.game.permanent.Permanent)13 TargetPermanent (mage.target.TargetPermanent)12 TargetAnyTarget (mage.target.common.TargetAnyTarget)11 UUID (java.util.UUID)6 Card (mage.cards.Card)6 FilterPermanent (mage.filter.FilterPermanent)6 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)5 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)4 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)4 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)3 DoWhenCostPaid (mage.abilities.effects.common.DoWhenCostPaid)3 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)3 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)3 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 Mode (mage.abilities.Mode)2 ManaCosts (mage.abilities.costs.mana.ManaCosts)2