Search in sources :

Example 1 with DiscardTargetCost

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

the class DiscipleOfDeceitEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    MageObject mageObject = game.getObject(source.getSourceId());
    if (player != null && mageObject != null) {
        Cost cost = new DiscardTargetCost(new TargetCardInHand(new FilterNonlandCard()));
        String message = "Discard a nonland card to search your library?";
        if (cost.canPay(source, source, source.getControllerId(), game) && player.chooseUse(Outcome.Detriment, message, source, game)) {
            if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
                Card card = game.getCard(cost.getTargets().getFirstTarget());
                if (card == null) {
                    return false;
                }
                String targetName = "card with mana value of " + card.getManaValue();
                FilterCard filter = new FilterCard(targetName);
                filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, card.getManaValue()));
                return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true, true).apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterNonlandCard(mage.filter.common.FilterNonlandCard) TargetCardInHand(mage.target.common.TargetCardInHand) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) MageObject(mage.MageObject) SearchLibraryPutInHandEffect(mage.abilities.effects.common.search.SearchLibraryPutInHandEffect) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) Cost(mage.abilities.costs.Cost) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) FilterNonlandCard(mage.filter.common.FilterNonlandCard) Card(mage.cards.Card)

Example 2 with DiscardTargetCost

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

the class BlindZealotTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player opponent = game.getPlayer(event.getPlayerId());
    if (opponent == null || !event.getSourceId().equals(getSourceId()) || !((DamagedEvent) event).isCombatDamage()) {
        return false;
    }
    FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent("creature or planeswalker" + opponent.getLogName() + " controls");
    filter.add(new ControllerIdPredicate(opponent.getId()));
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DestroyTargetEffect(), false, "destroy target creature or planeswalker that player controls");
    this.getEffects().clear();
    this.addEffect(new DoWhenCostPaid(ability, new DiscardTargetCost(new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE)), "Discard a creature card?"));
    return true;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) DamagedEvent(mage.game.events.DamagedEvent) DoWhenCostPaid(mage.abilities.effects.common.DoWhenCostPaid) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) TargetCardInHand(mage.target.common.TargetCardInHand) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) FilterCreatureOrPlaneswalkerPermanent(mage.filter.common.FilterCreatureOrPlaneswalkerPermanent)

Example 3 with DiscardTargetCost

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

the class PainfulQuandryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    if (player != null) {
        boolean paid = false;
        Cost cost = new DiscardTargetCost(new TargetCardInHand());
        if (cost.canPay(source, source, player.getId(), game) && player.chooseUse(Outcome.Detriment, "Discard a card (otherwise you lose 5 life)?", source, game)) {
            paid = cost.pay(source, game, source, player.getId(), false, null);
        }
        if (!paid) {
            player.loseLife(5, game, source, false);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) Cost(mage.abilities.costs.Cost)

Example 4 with DiscardTargetCost

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

the class UrzasHotTubPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Cost cost : source.getCosts()) {
        if (cost instanceof DiscardTargetCost) {
            DiscardTargetCost discardCost = (DiscardTargetCost) cost;
            Card discardedCard = discardCost.getCards().get(0);
            if (discardedCard != null) {
                FilterCard filter = new FilterCard();
                filter.add(new UrzasHotTubPredicate(discardedCard.getName()));
                return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true, true).apply(game, source);
            }
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) SearchLibraryPutInHandEffect(mage.abilities.effects.common.search.SearchLibraryPutInHandEffect) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) Cost(mage.abilities.costs.Cost) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard)

Example 5 with DiscardTargetCost

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

the class UrzasHotTubPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Cost cost : source.getCosts()) {
        if (cost instanceof DiscardTargetCost) {
            DiscardTargetCost discardCost = (DiscardTargetCost) cost;
            Card discardedCard = discardCost.getCards().get(0);
            if (discardedCard != null) {
                FilterCard filter = new FilterCard();
                filter.add(new UrzasHotTubPredicate(discardedCard.getName()));
                return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true, true).apply(game, source);
            }
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) SearchLibraryPutInHandEffect(mage.abilities.effects.common.search.SearchLibraryPutInHandEffect) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard)

Aggregations

DiscardTargetCost (mage.abilities.costs.common.DiscardTargetCost)8 Cost (mage.abilities.costs.Cost)6 Player (mage.players.Player)6 TargetCardInHand (mage.target.common.TargetCardInHand)6 FilterCard (mage.filter.FilterCard)5 SearchLibraryPutInHandEffect (mage.abilities.effects.common.search.SearchLibraryPutInHandEffect)3 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)3 UUID (java.util.UUID)2 MageObject (mage.MageObject)2 Permanent (mage.game.permanent.Permanent)2 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)1 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)1 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)1 DestroyTargetEffect (mage.abilities.effects.common.DestroyTargetEffect)1 DoWhenCostPaid (mage.abilities.effects.common.DoWhenCostPaid)1 Card (mage.cards.Card)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)1 FilterCreatureOrPlaneswalkerPermanent (mage.filter.common.FilterCreatureOrPlaneswalkerPermanent)1 FilterLandCard (mage.filter.common.FilterLandCard)1