Search in sources :

Example 6 with DiscardCardCost

use of mage.abilities.costs.common.DiscardCardCost in project mage by magefree.

the class LandsEdgeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        DiscardCardCost cost = (DiscardCardCost) source.getCosts().get(0);
        if (cost != null) {
            List<Card> cards = cost.getCards();
            if (cards.size() == 1 && cards.get(0).isLand(game)) {
                Effect effect = new DamageTargetEffect(2);
                effect.setTargetPointer(getTargetPointer());
                effect.apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : DiscardCardCost(mage.abilities.costs.common.DiscardCardCost) Player(mage.players.Player) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) InfoEffect(mage.abilities.effects.common.InfoEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) Card(mage.cards.Card)

Example 7 with DiscardCardCost

use of mage.abilities.costs.common.DiscardCardCost in project mage by magefree.

the class MishrasWarMachineEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (controller != null && sourcePermanent != null) {
        DiscardCardCost cost = new DiscardCardCost();
        if (controller.chooseUse(Outcome.Benefit, "Discard a card to prevent the damage?", source, game) && cost.canPay(source, source, source.getControllerId(), game) && cost.pay(source, game, source, source.getControllerId(), true)) {
            return true;
        }
        if (controller.damage(3, sourcePermanent.getId(), source, game) > 0) {
            sourcePermanent.tap(source, game);
            return true;
        }
    }
    return false;
}
Also used : DiscardCardCost(mage.abilities.costs.common.DiscardCardCost) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent)

Example 8 with DiscardCardCost

use of mage.abilities.costs.common.DiscardCardCost in project mage by magefree.

the class DemonicEmbracePlayEffect method applies.

@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
    if (sourceId.equals(source.getSourceId()) && source.isControlledBy(affectedControllerId)) {
        if (game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
            Player player = game.getPlayer(affectedControllerId);
            if (player != null) {
                Costs<Cost> costs = new CostsImpl<>();
                costs.add(new PayLifeCost(3));
                costs.add(new DiscardCardCost());
                player.setCastSourceIdWithAlternateMana(sourceId, new ManaCostsImpl<>("{1}{B}{B}"), costs);
                return true;
            }
        }
    }
    return false;
}
Also used : DiscardCardCost(mage.abilities.costs.common.DiscardCardCost) Player(mage.players.Player) CostsImpl(mage.abilities.costs.CostsImpl) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) PayLifeCost(mage.abilities.costs.common.PayLifeCost) PayLifeCost(mage.abilities.costs.common.PayLifeCost) DiscardCardCost(mage.abilities.costs.common.DiscardCardCost) Cost(mage.abilities.costs.Cost)

Aggregations

DiscardCardCost (mage.abilities.costs.common.DiscardCardCost)8 Player (mage.players.Player)7 Cost (mage.abilities.costs.Cost)5 Effect (mage.abilities.effects.Effect)3 Card (mage.cards.Card)3 Permanent (mage.game.permanent.Permanent)3 UUID (java.util.UUID)2 OneShotEffect (mage.abilities.effects.OneShotEffect)2 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)2 SpellAbility (mage.abilities.SpellAbility)1 Costs (mage.abilities.costs.Costs)1 CostsImpl (mage.abilities.costs.CostsImpl)1 PayLifeCost (mage.abilities.costs.common.PayLifeCost)1 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 DoIfCostPaid (mage.abilities.effects.common.DoIfCostPaid)1 InfoEffect (mage.abilities.effects.common.InfoEffect)1 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)1 AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)1 Spell (mage.game.stack.Spell)1