Search in sources :

Example 1 with DoIfCostPaid

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

the class ValentinDeanOfTheVeinEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    ((ZoneChangeEvent) event).setToZone(Zone.EXILED);
    game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new DoIfCostPaid(new CreateTokenEffect(new Pest11GainLifeToken()), new GenericManaCost(2)), false, "you may pay {2}. If you do, create a 1/1 black and green " + "Pest creature token with \"When this creature dies, you gain 1 life.\""), source);
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) DoIfCostPaid(mage.abilities.effects.common.DoIfCostPaid) Pest11GainLifeToken(mage.game.permanent.token.Pest11GainLifeToken) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 2 with DoIfCostPaid

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

the class CemeteryPucaEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent copyToCreature = game.getPermanent(source.getSourceId());
    if (copyToCreature != null) {
        Permanent copyFromCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
        if (copyFromCreature != null) {
            game.copyPermanent(Duration.WhileOnBattlefield, copyFromCreature, copyToCreature.getId(), source, new EmptyCopyApplier());
            ContinuousEffect effect = new GainAbilityTargetEffect(new DiesCreatureTriggeredAbility(new DoIfCostPaid(new CemeteryPucaEffect(), new ManaCostsImpl("{1}")), false, StaticFilters.FILTER_PERMANENT_A_CREATURE, true), Duration.WhileOnBattlefield);
            effect.setTargetPointer(new FixedTarget(copyToCreature.getId(), game));
            game.addEffect(effect, source);
            return true;
        }
    }
    return false;
}
Also used : DiesCreatureTriggeredAbility(mage.abilities.common.DiesCreatureTriggeredAbility) FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) DoIfCostPaid(mage.abilities.effects.common.DoIfCostPaid) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 3 with DoIfCostPaid

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

the class WolfOfDevilsBreachDiscardCostCardConvertedManaCount method calculate.

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
    for (Effect sourceEffect : sourceAbility.getEffects()) {
        if (sourceEffect instanceof DoIfCostPaid) {
            Cost doCosts = ((DoIfCostPaid) sourceEffect).getCost();
            if (doCosts instanceof Costs) {
                Costs costs = (Costs) doCosts;
                for (Object cost : costs) {
                    if (cost instanceof DiscardCardCost) {
                        DiscardCardCost discardCost = (DiscardCardCost) cost;
                        int cmc = 0;
                        for (Card card : discardCost.getCards()) {
                            cmc += card.getManaValue();
                        }
                        return cmc;
                    }
                }
            }
        }
    }
    return 0;
}
Also used : DiscardCardCost(mage.abilities.costs.common.DiscardCardCost) Costs(mage.abilities.costs.Costs) DoIfCostPaid(mage.abilities.effects.common.DoIfCostPaid) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) DiscardCardCost(mage.abilities.costs.common.DiscardCardCost) Cost(mage.abilities.costs.Cost) Card(mage.cards.Card)

Example 4 with DoIfCostPaid

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

the class SpiritSistersCallPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID targetId = source.getFirstTarget();
    Card card = game.getCard(targetId);
    if (card == null || game.getState().getZone(targetId) != Zone.GRAVEYARD) {
        return false;
    }
    FilterControlledPermanent filter = new FilterControlledPermanent("a permanent that shares a card type with the chosen card");
    filter.add(new SpiritSistersCallPredicate(new HashSet<CardType>(card.getCardType(game))));
    return new DoIfCostPaid(new SpiritSistersCallReturnToBattlefieldEffect(), new SacrificeTargetCost(filter)).apply(game, source);
}
Also used : SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) DoIfCostPaid(mage.abilities.effects.common.DoIfCostPaid) UUID(java.util.UUID) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Card(mage.cards.Card) FilterPermanentCard(mage.filter.common.FilterPermanentCard) HashSet(java.util.HashSet)

Example 5 with DoIfCostPaid

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

the class PreferredSelectionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 2));
    player.lookAtCards(source, "Top two cards", cards, game);
    Cost cost = new CompositeCost(new SacrificeSourceCost(), new ManaCostsImpl<>("{2}{G}{G}"), "sacrifice this permanent and pay {2}{G}{G}");
    return new DoIfCostPaid(new LookLibraryAndPickControllerEffect(StaticValue.get(2), false, StaticValue.get(1), StaticFilters.FILTER_CARD, Zone.HAND, true, false), new LookLibraryAndPickControllerEffect(StaticValue.get(2), false, StaticValue.get(1), StaticFilters.FILTER_CARD, Zone.HAND, true, false, false, Zone.LIBRARY, false, true, false), cost).apply(game, source);
}
Also used : Player(mage.players.Player) CompositeCost(mage.abilities.costs.CompositeCost) SacrificeSourceCost(mage.abilities.costs.common.SacrificeSourceCost) DoIfCostPaid(mage.abilities.effects.common.DoIfCostPaid) LookLibraryAndPickControllerEffect(mage.abilities.effects.common.LookLibraryAndPickControllerEffect) SacrificeSourceCost(mage.abilities.costs.common.SacrificeSourceCost) Cost(mage.abilities.costs.Cost) CompositeCost(mage.abilities.costs.CompositeCost) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Aggregations

DoIfCostPaid (mage.abilities.effects.common.DoIfCostPaid)5 Cost (mage.abilities.costs.Cost)2 Card (mage.cards.Card)2 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 DiesCreatureTriggeredAbility (mage.abilities.common.DiesCreatureTriggeredAbility)1 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)1 CompositeCost (mage.abilities.costs.CompositeCost)1 Costs (mage.abilities.costs.Costs)1 DiscardCardCost (mage.abilities.costs.common.DiscardCardCost)1 SacrificeSourceCost (mage.abilities.costs.common.SacrificeSourceCost)1 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)1 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 Effect (mage.abilities.effects.Effect)1 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)1 LookLibraryAndPickControllerEffect (mage.abilities.effects.common.LookLibraryAndPickControllerEffect)1 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)1