Search in sources :

Example 1 with CardsInAllGraveyardsCount

use of mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount in project mage by magefree.

the class NamelessRaceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanentEntering(source.getSourceId());
    if (controller == null || permanent == null) {
        return false;
    }
    int permanentsInPlay = new PermanentsOnBattlefieldCount(filter).calculate(game, source, null);
    int cardsInGraveyards = new CardsInAllGraveyardsCount(filter2).calculate(game, source, null);
    int maxAmount = Math.min(permanentsInPlay + cardsInGraveyards, controller.getLife());
    int payAmount = controller.getAmount(0, maxAmount, "Pay up to " + maxAmount + " life", game);
    Cost cost = new PayLifeCost(payAmount);
    if (!cost.pay(source, game, source, source.getControllerId(), true)) {
        return false;
    }
    Card sourceCard = game.getCard(source.getSourceId());
    game.informPlayers((sourceCard != null ? sourceCard.getLogName() : "") + ": " + controller.getLogName() + " pays " + payAmount + " life");
    game.addEffect(new SetPowerToughnessSourceEffect(payAmount, payAmount, Duration.Custom, SubLayer.CharacteristicDefining_7a), source);
    permanent.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game);
    return true;
}
Also used : SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) CardsInAllGraveyardsCount(mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount) PayLifeCost(mage.abilities.costs.common.PayLifeCost) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) Cost(mage.abilities.costs.Cost) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 2 with CardsInAllGraveyardsCount

use of mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount in project mage by magefree.

the class TheMimeoplasmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanentEntering(source.getSourceId());
    if (controller != null && permanent != null) {
        if (new CardsInAllGraveyardsCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this) >= 2) {
            if (controller.chooseUse(Outcome.Benefit, "Do you want to exile two creature cards from graveyards?", source, game)) {
                TargetCardInGraveyard targetCopy = new TargetCardInGraveyard(new FilterCreatureCard("creature card to become a copy of"));
                targetCopy.setNotTarget(true);
                if (controller.choose(Outcome.Copy, targetCopy, source.getSourceId(), game)) {
                    Card cardToCopy = game.getCard(targetCopy.getFirstTarget());
                    if (cardToCopy != null) {
                        FilterCreatureCard filter = new FilterCreatureCard("creature card to determine amount of additional +1/+1 counters");
                        filter.add(Predicates.not(new CardIdPredicate(cardToCopy.getId())));
                        TargetCardInGraveyard targetCounters = new TargetCardInGraveyard(filter);
                        targetCounters.setNotTarget(true);
                        if (controller.choose(Outcome.Copy, targetCounters, source.getSourceId(), game)) {
                            Card cardForCounters = game.getCard(targetCounters.getFirstTarget());
                            if (cardForCounters != null) {
                                Cards cardsToExile = new CardsImpl();
                                cardsToExile.add(cardToCopy);
                                cardsToExile.add(cardForCounters);
                                controller.moveCards(cardsToExile, Zone.EXILED, source, game);
                                CopyEffect copyEffect = new CopyEffect(Duration.Custom, cardToCopy, source.getSourceId());
                                game.addEffect(copyEffect, source);
                                permanent.addCounters(CounterType.P1P1.createInstance(cardForCounters.getPower().getValue()), source.getControllerId(), source, game);
                            }
                        }
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : CopyEffect(mage.abilities.effects.common.CopyEffect) Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Permanent(mage.game.permanent.Permanent) CardsInAllGraveyardsCount(mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount) FilterCreatureCard(mage.filter.common.FilterCreatureCard) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate)

Aggregations

CardsInAllGraveyardsCount (mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount)2 Permanent (mage.game.permanent.Permanent)2 Player (mage.players.Player)2 Cost (mage.abilities.costs.Cost)1 PayLifeCost (mage.abilities.costs.common.PayLifeCost)1 PermanentsOnBattlefieldCount (mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)1 CopyEffect (mage.abilities.effects.common.CopyEffect)1 SetPowerToughnessSourceEffect (mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect)1 Card (mage.cards.Card)1 FilterCard (mage.filter.FilterCard)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterCreatureCard (mage.filter.common.FilterCreatureCard)1 CardIdPredicate (mage.filter.predicate.mageobject.CardIdPredicate)1 TargetCardInGraveyard (mage.target.common.TargetCardInGraveyard)1