use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class DashHopesCounterSourceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null) {
PayLifeCost cost = new PayLifeCost(5);
for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
cost.clearPaid();
if (cost.canPay(source, source, player.getId(), game) && player.chooseUse(outcome, "Pay 5 life to counter " + sourceObject.getIdName() + '?', source, game)) {
if (cost.pay(source, game, source, player.getId(), false, null)) {
game.informPlayers(player.getLogName() + " pays 5 life to counter " + sourceObject.getIdName() + '.');
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {
game.getStack().counter(spell.getId(), source, game);
}
}
}
}
}
return true;
}
return false;
}
use of mage.abilities.costs.common.PayLifeCost 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;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class AetherRiftEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = controller.discardOne(true, false, source, game);
if (card != null && card.isCreature(game)) {
Effect returnEffect = new ReturnFromGraveyardToBattlefieldTargetEffect();
returnEffect.setTargetPointer(new FixedTarget(card.getId(), game));
Effect doEffect = new DoUnlessAnyPlayerPaysEffect(returnEffect, new PayLifeCost(5), "Pay 5 life to prevent " + card.getLogName() + " to return from graveyard to battlefield?");
return doEffect.apply(game, source);
}
return true;
}
return false;
}
Aggregations