Search in sources :

Example 31 with PayLifeCost

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;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) PayLifeCost(mage.abilities.costs.common.PayLifeCost) UUID(java.util.UUID) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell)

Example 32 with PayLifeCost

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

Example 33 with PayLifeCost

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;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) PayLifeCost(mage.abilities.costs.common.PayLifeCost) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) DoUnlessAnyPlayerPaysEffect(mage.abilities.effects.common.DoUnlessAnyPlayerPaysEffect) DoUnlessAnyPlayerPaysEffect(mage.abilities.effects.common.DoUnlessAnyPlayerPaysEffect) Card(mage.cards.Card)

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