Search in sources :

Example 21 with PayLifeCost

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

the class EssenceVortexEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    Cost cost = new PayLifeCost(permanent.getToughness().getValue());
    if (cost.pay(source, game, source, permanent.getControllerId(), true)) {
        return true;
    }
    return permanent.destroy(source, game, true);
}
Also used : Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cost(mage.abilities.costs.Cost) PayLifeCost(mage.abilities.costs.common.PayLifeCost)

Example 22 with PayLifeCost

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

the class ForceChokeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    StackObject stackObject = (StackObject) game.getObject(getTargetPointer().getFirst(game, source));
    Player objectController = game.getPlayer(stackObject.getControllerId());
    if (player != null) {
        Cost cost = new PayLifeCost(stackObject.getManaValue());
        if (cost.canPay(source, source, objectController.getId(), game) && objectController.chooseUse(Outcome.LoseLife, "Pay " + stackObject.getManaValue() + " life?", source, game) && cost.pay(source, game, source, objectController.getId(), false, null)) {
            objectController.moveCards((Card) stackObject, Zone.HAND, source, game);
        } else {
            game.getStack().counter(stackObject.getId(), source, game);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) StackObject(mage.game.stack.StackObject) PayLifeCost(mage.abilities.costs.common.PayLifeCost) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cost(mage.abilities.costs.Cost)

Example 23 with PayLifeCost

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

the class PrinceOfThrallsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card card = game.getCard(targetPointer.getFirst(game, source));
    Permanent permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
    if (controller != null && card != null && permanent != null) {
        Player opponent = game.getPlayer(permanent.getControllerId());
        if (opponent != null) {
            PayLifeCost cost = new PayLifeCost(3);
            if (opponent.chooseUse(Outcome.Neutral, cost.getText() + " or " + card.getLogName() + " comes back into the battlefield under opponents control", source, game)) {
                cost.clearPaid();
                if (cost.pay(source, game, source, opponent.getId(), true, null)) {
                    return true;
                }
            }
            controller.moveCards(card, Zone.BATTLEFIELD, source, game);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Card(mage.cards.Card)

Example 24 with PayLifeCost

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

the class AbilityImpl method handlePhyrexianManaCosts.

/**
 * 601.2b If a cost that will be paid as the spell is being cast includes
 * Phyrexian mana symbols, the player announces whether they intend to pay 2
 * life or the corresponding colored mana cost for each of those symbols.
 */
private void handlePhyrexianManaCosts(Game game, Player controller) {
    Iterator<ManaCost> costIterator = manaCostsToPay.iterator();
    while (costIterator.hasNext()) {
        ManaCost cost = costIterator.next();
        if (!cost.isPhyrexian()) {
            continue;
        }
        PayLifeCost payLifeCost = new PayLifeCost(2);
        if (payLifeCost.canPay(this, this, controller.getId(), game) && controller.chooseUse(Outcome.LoseLife, "Pay 2 life instead of " + cost.getText().replace("/P", "") + '?', this, game)) {
            costIterator.remove();
            costs.add(payLifeCost);
            manaCostsToPay.incrPhyrexianPaid();
        }
    }
}
Also used : VariableManaCost(mage.abilities.costs.mana.VariableManaCost) ManaCost(mage.abilities.costs.mana.ManaCost) PayLifeCost(mage.abilities.costs.common.PayLifeCost)

Example 25 with PayLifeCost

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

the class GiantAlbatrossEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (sourcePermanent != null && controller != null) {
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game);
                Cost cost = new PayLifeCost(2);
                for (Permanent creature : creatures) {
                    if (sourcePermanent.getDealtDamageByThisTurn().contains(new MageObjectReference(creature.getId(), game))) {
                        final StringBuilder sb = new StringBuilder("Pay 2 life? (Otherwise ").append(creature.getName()).append(" will be destroyed)");
                        if (cost.canPay(source, source, creature.getControllerId(), game) && player.chooseUse(Outcome.Benefit, sb.toString(), source, game)) {
                            cost.pay(source, game, source, creature.getControllerId(), true, null);
                        }
                        if (!cost.isPaid()) {
                            creature.destroy(source, game, true);
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) PayLifeCost(mage.abilities.costs.common.PayLifeCost) UUID(java.util.UUID) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cost(mage.abilities.costs.Cost) MageObjectReference(mage.MageObjectReference)

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