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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations