Search in sources :

Example 6 with PayLifeCost

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;
}
Also used : Player(mage.players.Player) PayLifeCost(mage.abilities.costs.common.PayLifeCost)

Example 7 with PayLifeCost

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;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) PayLifeCost(mage.abilities.costs.common.PayLifeCost) UUID(java.util.UUID)

Example 8 with PayLifeCost

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;
}
Also used : CommanderPlaysCountWatcher(mage.watchers.common.CommanderPlaysCountWatcher) PayLifeCost(mage.abilities.costs.common.PayLifeCost)

Example 9 with PayLifeCost

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;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 10 with PayLifeCost

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;
}
Also used : Player(mage.players.Player) CostsImpl(mage.abilities.costs.CostsImpl) PayLifeCost(mage.abilities.costs.common.PayLifeCost) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cost(mage.abilities.costs.Cost)

Aggregations

PayLifeCost (mage.abilities.costs.common.PayLifeCost)33 Player (mage.players.Player)26 Cost (mage.abilities.costs.Cost)17 Card (mage.cards.Card)12 Permanent (mage.game.permanent.Permanent)12 UUID (java.util.UUID)6 MageObject (mage.MageObject)6 CostsImpl (mage.abilities.costs.CostsImpl)3 CardsImpl (mage.cards.CardsImpl)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 Ability (mage.abilities.Ability)2 EntersBattlefieldTriggeredAbility (mage.abilities.common.EntersBattlefieldTriggeredAbility)2 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)2 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)2 ManaCost (mage.abilities.costs.mana.ManaCost)2 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)2 SetPowerToughnessSourceEffect (mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect)2 Cards (mage.cards.Cards)2 ApprovingObject (mage.ApprovingObject)1 MageObjectReference (mage.MageObjectReference)1