use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class BreathstealersCryptEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player player = game.getPlayer(event.getPlayerId());
if (player == null) {
return false;
}
Card cardDrawn = player.getLibrary().getFromTop(game);
// even if the draw is replaced by another draw (such as with Enduring Renewal).
if (cardDrawn == null || player.drawCards(1, source, game, event) != 1) {
return true;
}
player.revealCards(source, new CardsImpl(cardDrawn), game);
if (!cardDrawn.isCreature(game)) {
return true;
}
game.informPlayers("The card drawn by " + player.getName() + " is a creature card. They discard that card unless they pay 3 life.");
PayLifeCost cost = new PayLifeCost(3);
if (!cost.canPay(source, source, player.getId(), game) || !player.chooseUse(outcome, "Pay 3 life or discard " + cardDrawn.getIdName() + "?", null, "Pay 3 life", "Discard", source, game) || !cost.pay(source, game, source, player.getId(), true, cost)) {
player.discard(cardDrawn, false, source, game);
}
return true;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class CleansingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Iterator<Permanent> permanents = game.getBattlefield().getActivePermanents(source.getControllerId(), game).iterator();
while (permanents.hasNext()) {
boolean paidLife = false;
Permanent p = permanents.next();
if (p.isLand(game)) {
game.informPlayers("Any player may pay 1 life to prevent the destruction of " + p.getLogName() + " controlled by " + game.getPlayer(p.getControllerId()).getLogName() + ".");
PayLifeCost cost = new PayLifeCost(1);
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 1 life to prevent this?", source, game)) {
if (cost.pay(source, game, source, player.getId(), false, null)) {
game.informPlayers(player.getLogName() + " pays 1 life to prevent the destruction of " + p.getLogName());
paidLife = true;
}
}
}
}
if (!paidLife) {
p.destroy(source, game, false);
}
}
}
return true;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class LiesaShroudOfDusk method commanderCost.
@Override
public boolean commanderCost(Game game, Ability source, Ability abilityToModify) {
CommanderPlaysCountWatcher watcher = game.getState().getWatcher(CommanderPlaysCountWatcher.class);
int castCount = watcher.getPlaysCount(getMainCard().getId());
if (castCount > 0) {
abilityToModify.addCost(new PayLifeCost(2 * castCount));
}
return true;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class MoonlightBargainEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
Set<Card> topFive = controller.getLibrary().getTopCards(game, 5);
Cards lookAtCards = new CardsImpl();
lookAtCards.addAll(topFive);
controller.lookAtCards(sourceObject.getIdName(), lookAtCards, game);
Cards toHand = new CardsImpl();
for (Card card : topFive) {
PayLifeCost cost = new PayLifeCost(2);
if (cost.canPay(source, source, source.getControllerId(), game)) {
if (controller.chooseUse(outcome, "Put " + card.getIdName() + " into your graveyard unless you pay 2 life", sourceObject.getIdName(), "Pay 2 life and put into hand", "Put into your graveyard", source, game)) {
if (cost.pay(source, game, source, source.getControllerId(), false)) {
toHand.add(card);
} else {
controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
} else {
controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
}
}
controller.moveCards(toHand, Zone.HAND, source, game);
return true;
}
return false;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class NashiMoonSagesScionPlayEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (!super.applies(objectId, source, affectedControllerId, game) || !NashiMoonSagesScionWatcher.checkCard(game, source, mor)) {
return false;
}
Card cardToCheck = mor.getCard(game);
if (cardToCheck.isLand(game)) {
return true;
}
// allows to play/cast with alternative life cost
Player controller = game.getPlayer(source.getControllerId());
PayLifeCost lifeCost = new PayLifeCost(cardToCheck.getSpellAbility().getManaCosts().manaValue());
Costs<Cost> newCosts = new CostsImpl<>();
newCosts.add(lifeCost);
newCosts.addAll(cardToCheck.getSpellAbility().getCosts());
controller.setCastSourceIdWithAlternateMana(cardToCheck.getId(), null, newCosts);
return true;
}
Aggregations