Search in sources :

Example 6 with ExileFromGraveCost

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

the class FlashOfInsightEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller == null || sourceObject == null) {
        return false;
    }
    int xValue = source.getManaCostsToPay().getX();
    for (Cost cost : source.getCosts()) {
        if (cost instanceof ExileFromGraveCost) {
            xValue = ((ExileFromGraveCost) cost).getExiledCards().size();
        }
    }
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
    controller.lookAtCards(sourceObject.getIdName(), cards, game);
    TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
    target.setNotTarget(true);
    if (controller.chooseTarget(Outcome.DrawCard, cards, target, source, game)) {
        Card card = cards.get(target.getFirstTarget(), game);
        if (card != null) {
            controller.moveCards(card, Zone.HAND, source, game);
            cards.remove(card);
        }
    }
    controller.putCardsOnBottomOfLibrary(cards, game, source, true);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) ExileXFromYourGraveCost(mage.abilities.costs.common.ExileXFromYourGraveCost) Cost(mage.abilities.costs.Cost) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard)

Example 7 with ExileFromGraveCost

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

the class OsgirTheReconstructorCreateArtifactTokensEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Card card = null;
    for (Cost cost : source.getCosts()) {
        if (!(cost instanceof ExileFromGraveCost)) {
            continue;
        }
        card = ((ExileFromGraveCost) cost).getExiledCards().get(0);
    }
    if (player == null || card == null) {
        return false;
    }
    CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(player.getId(), null, false, 2);
    effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
    effect.apply(game, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) VariableManaCost(mage.abilities.costs.mana.VariableManaCost) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TapSourceCost(mage.abilities.costs.common.TapSourceCost) VariableCost(mage.abilities.costs.VariableCost) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Card(mage.cards.Card) FilterArtifactCard(mage.filter.common.FilterArtifactCard) FilterCard(mage.filter.FilterCard)

Example 8 with ExileFromGraveCost

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

the class TaigamSidisisHandEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (targetCreature != null) {
            int amount = 0;
            for (Cost cost : source.getCosts()) {
                if (cost instanceof ExileFromGraveCost) {
                    amount = ((ExileFromGraveCost) cost).getExiledCards().size();
                    ContinuousEffect effect = new BoostTargetEffect(-amount, -amount, Duration.EndOfTurn);
                    effect.setTargetPointer(new FixedTarget(source.getTargets().getFirstTarget(), game));
                    game.addEffect(effect, source);
                }
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Cost(mage.abilities.costs.Cost) TapSourceCost(mage.abilities.costs.common.TapSourceCost) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost)

Example 9 with ExileFromGraveCost

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

the class WebOfInertiaRestrictionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (player != null && sourceObject != null) {
        Cost cost = new ExileFromGraveCost(new TargetCardInYourGraveyard());
        if (cost.canPay(source, source, player.getId(), game) && player.chooseUse(Outcome.Detriment, "Exile a card from your graveyard?", source, game)) {
            cost.clearPaid();
            if (cost.pay(source, game, source, player.getId(), false, null)) {
                if (!game.isSimulation()) {
                    game.informPlayers(player.getLogName() + " pays the cost to prevent the effect");
                }
            }
        } else {
            game.addEffect(new WebOfInertiaRestrictionEffect(player.getId()), source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) MageObject(mage.MageObject) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Cost(mage.abilities.costs.Cost) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost)

Aggregations

ExileFromGraveCost (mage.abilities.costs.common.ExileFromGraveCost)9 Player (mage.players.Player)9 Cost (mage.abilities.costs.Cost)7 FilterCard (mage.filter.FilterCard)4 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)4 TapSourceCost (mage.abilities.costs.common.TapSourceCost)3 MageObject (mage.MageObject)2 Card (mage.cards.Card)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 SpecialAction (mage.abilities.SpecialAction)1 CostsImpl (mage.abilities.costs.CostsImpl)1 VariableCost (mage.abilities.costs.VariableCost)1 ExileXFromYourGraveCost (mage.abilities.costs.common.ExileXFromYourGraveCost)1 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)1 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 VariableManaCost (mage.abilities.costs.mana.VariableManaCost)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)1 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1