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